Hi,
When my app start it checks if certain file in a certain directory exist and if they don't exist creates them.
Later my app tries to read from that file but an exception is thrown:
System.IO.IOException: The process cannot access the file 'c:\test\a.txt' because it is being used by another process. and it goes on and on with this message.
I have written a small test program to show what I do and what is my problem.
What I am doing wrong? Please.Code:try { if (System.IO.Directory.Exists("c://test") == false) System.IO.Directory.CreateDirectory("c://test"); if (System.IO.File.Exists("c://test") == false) System.IO.File.Create("c://test//a.txt"); using (System.IO.StreamReader sr = System.IO.File.OpenText("c://test//a.txt")) { System.Windows.MessageBox.Show("success!"); } } catch (Exception e) { System.Windows.MessageBox.Show(e.ToString(), "Why??"); throw; }