I am attempting to move a file, but I am receiving an exception stating that the file cannot be moved because it is in use. I realize this is a common error, and also that my application is the one that is keeping the file open, but what I don't know is where.
I am opening the file (.html) using the Html Agility Pack, which has a .Load method. There is not a way, that I know of, to unload or close a document once open. Other than that, I scrape some data from the .html document but not a lot more. I am also downloading a file (using webclient) from a link from the .html file, but I cannot move that file either. Note my code below.
I am opening the file (.html) using the Html Agility Pack, which has a .Load method. There is not a way, that I know of, to unload or close a document once open. Other than that, I scrape some data from the .html document but not a lot more. I am also downloading a file (using webclient) from a link from the .html file, but I cannot move that file either. Note my code below.
Code:
private void DeleteFiles(string strPODoc)
{
string strDestination;
string strPOFile = ParseString(strPODoc, @"c:\");
strDestination=@"\\epsa\orders\PROCESSED\";
if (File.Exists(strPODoc))
{
File.Move(strPODoc, strDestination + strPOFile);
Console.WriteLine(strPODoc + " has been processed");
}
else
{
Console.WriteLine(strPODoc + " does not exist");
Console.Read();
}
}
Comment