Reputation: 3945
At the end of the month I copy a file over to a different location and remove the original:
System.IO.File.Copy(fileLocation + PLU.FolderPath, destinationFilePath, true);
System.IO.File.Delete(PLU.FolderPath);
The file copies but it doesnt remove, it doesnt remove because the file doesnt exist. PLU.FolderPath holds: PLU_104.DAT, which is why I need to use the 'fileLocation + PLU.FolderPath' in the copy.
Shouldnt it throw an error if it doesnt delete though? Even if the file it is looking for is not there? I've tried it inside a try catch but it still doesnt throw an error:
System.IO.File.Copy(fileLocation + PLU.FolderPath, destinationFilePath, true);
try
{
System.IO.File.Delete(PLU.FolderPath);
}
catch (Exception e)
{
Log.Quiet("Didnt delete" + e.Message);
}
Upvotes: 0
Views: 66
Reputation: 4672
From Msdn
If the file to be deleted does not exist, no exception is thrown.
http://msdn.microsoft.com/en-us/library/system.io.file.delete(v=vs.110).aspx
Upvotes: 1