3
Answers

Creating and writting file

Mayur  Gujrathi

Mayur Gujrathi

13y
2.3k
1
string path = "C:\\mytest.txt";
 

 
            if (File.Exists(path))
            {
                File.Delete(path);
            }
 

            using (FileStream fs = File.Create(path))
            {
                //fs.Close();
              // fs.CanWrite = true;
          TextWriter sw = new StreamWriter("C:\\mytest.txt");//error is coming here
          sw.WriteLine("ddd", "dddd", "dsdsd");
          --------------
          -------------
          --------
            }
 
I am trying to create and write to text file but is giving error file is being used by another person
Answers (3)
Next Recommended Forum