here is my code:
public static bool createFile(string dir) {
dir="c:\\e.bat";
System.IO.File.Create(dir);
if (System.IO.File.Exists(dir))
{
try
{
StreamWriter SW;
SW = System.IO.File.CreateText(dir);
SW.WriteLine("something ");
SW.Close();
}
catch (Exception e)
{
Console.Write(e.Message);
Console.ReadLine();
return false;
}
}
return true;
}
here dir is the current directory. i am facing the error The process cannot access the file because it is being used by another process.how can i solve this problem?