I am trying to create a file named "test.txt" in a folder named "test" in the current directory and append some lines of text into it.
I am using this code segment in a program but getting an exception saying that the file is already in use by another process
. Is there any problem in this segment?
DateTime now = DateTime.Now;
string time = now.ToString();
string id="test";
string path2 = Path.Combine(Environment.CurrentDirectory, id);
string path=Directory.GetCurrentDirectory();
string FileName = Path.Combine(path2, id + ".txt");
File.Create(FileName);
string fullPathName2 = Path.GetFullPath(FileName);
File.AppendAllText(fullPathName2, time + Environment.NewLine);