1
Answer

Creting and writting text file

Mayur  Gujrathi

Mayur Gujrathi

12y
1.1k
1
Dear friends

I am creating on .txt file like this

FileStream fileStream = new FileStream(@"C:\mayur.txt", FileMode.Create);

file is created

on next line i am trying to initialise one writer

TextWriter sw = new StreamWriter(@"C:\\mayur.txt");

but it is giving error file is being used by another person on this line

when I create file manually and then this code works fine but this i am not creating file in code

How to solve this problem
Answers (1)