none
System.OutOfMemoryException: the specified buffer size is too large,FileSystemWatcher Unable to allocate 8192 bytes internal buffer, RRS feed

  • Question

  • I have a application for winfrom, always running ,the application include follow code:

    public class DataAccess
    {
      private static System.IO.FileSystemWatcher watcher ;
      public void TextCheck()
     {
       if (watcher == null)
       {
         watcher = new System.IO.FileSystemWatcher();
         watcher.Path = System.IO.Path.Combine (AppDomain.CurrentDomain.BaseDirectory);
         watcher.Filter = "*.txt";
         watcher.Changed += new System.IO.FileSystemEventHandler(watcher_Changed);
         watcher.IncludeSubdirectories = true;
         watcher.EnableRaisingEvents = true;
       }
     }
    }
    
    
    

    To sum up, we use code to monitor and control file for type of txt.

    then I have a question: the code always throw exception,details as follows

    System.OutOfMemoryException: the specified buffer size is too large,FileSystemWatcher Unable to allocate 8192 bytes internal buffer,     
    in System.IO.FileSystemWatcher.Monitor(IntPtr bufferPtr)     
    in System.IO.FileSystemWatcher.StartRaisingEvents()    
    in System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)

    Please help me ,thinks .

    Monday, December 27, 2010 1:56 AM