Hi,
I want to create a .txt file at the time of Sharepoint feature activation. I am able to create that file using this code
string fullFilePath = string.Format("{0}{1}", filePath, fileNmae); if (!System.IO.File.Exists(fullFilePath)) { FileStream fs = File.Create(string.Format("{0}{1}", filePath, string.Format(fileNmae))); fs.Close(); }
But Whenever I am trying to open and write something into that file,its giving an error "file is being used by another process".
f (System.IO.File.Exists(fullFilePath)) { using (FileStream fileStream = File.OpenRead(fullFilePath)) { File.WriteAllText(string.Format("{0}{1}", filePath, fileNmae), string.Join("{0}\n{1}\n{2}\n{3}", DateTime.Now.ToString(), msg, stackTrace, "xxxx")); } }Can you please tell me where I am wrong.
Shubho