c# - The process cannot access the file XXX because it is being used by another process -


when run application, error on first "using" here:

    public void createfile(string filepath)     {          //create file         string fileloc = filepath;          filestream fs = null;         if (!file.exists(fileloc))         {             using (fs = file.create(fileloc))             {              }         }      }      public void writefile(string filepath)     {         //write file         string fileloc = filepath;          if (file.exists(fileloc))         {             using (streamwriter sw = new streamwriter(fileloc))             {                 sw.write("some sample text file");             }         }     } 

a file directory opened , read from, streamreader closed after read. i'm not sure if has significance error. thanks.

your check of file.exists before line error suggests strange going on, such trying use directory path filepath, or multithreaded race conditions.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -