abdu

abdu

  • NA
  • 5
  • 3.4k

The process cannot access the file

Sep 9 2010 4:31 AM

hi
i have a program that i use to write data to an excel file....and at the same time i use an excel file to import data from the first excel file using (import data) tool
this is part of the program code
[code]
  StreamWriter theString = new



  StreamWriter(FileName + ".csv", true);







  theString.WriteLine(DateTime.Now +



  dataToSave + "\t\n");



  theString.Close();

[/code]
my problem is when i start to debuge my program in Visual C# 2008
it will work will and start to write data to the first excel file....then during the debug process
i want to import data from the first excel file to the second one using import data(it's important for me to do that in real time i cant delay the import process)
the debuging process stopped and the visual C# 2008  higlight this line of the code
[code]
 theString.Close();
[/code]
and a message popup to me said
The process cannot access the file because another process has locked a portion of the file.
any help in overcome this problem plz
and thanks

Answers (3)