because it is being used by another process

Posted by Naraayanan under Error and Solution on 6/17/2013 | Points: 10 | Views : 967 | Status : [Member] | Replies : 2

Hi All,
I am working File Management. Sometimes , I am getting the following error,"because it is being used by another process ".
Two Scenario.
Delete file:
I have one button . I just want to delete and update some data on the same file.
Move button
i want to move all the files from one folder to another folder at run time.

How can i resolve this issues?

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/



Responses

Posted by: Allemahesh on: 6/17/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Try adding a call to GC.Collect() after you have disposed of your streams to force the garbage collector to clean up.
Hope this will help to solve you problem.

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chaithragm on: 6/17/2013 [Member] Starter | Points: 25

Up
0
Down
if any files are opened like word.doc it will through the error make sure all the files are closed when u click on move button
or use this code it will automatically close the opened files.
put this in global declaration
System.Diagnostics.Process process;
static bool processflag=false;

//this code in the move button click
try
{

if (processflag)
{
if (process.HasExited)
{
processflag = false;
}
else
{

process.Kill();
processflag = false;
}
}

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response