Problem-
The process cannot access the file because it is being used by another process
This is common problem, when we create file using File.Create() method.
Reason-
When we use File.Create() method to create file then the object of FileStream class is created and no other process can use or access the created file until the file is closed.
Solution -
This problem can be easily resolved by modifying your code like this-
File.Create (@"c:\Text.txt").Close();
Means use Close () with File.Create () method. It will create the file and after that it will close the related file.
No comments:
Post a Comment