So I have some code that allows a user to import certain excel spreadsheets into the DB. Now, I save a copy of the file to the server so I can read it:
fupMYfile.SaveAs(System.IO.Path.Combine(target, fupMYfile.FileName));
So all works well there till i try to delete the file when I am done with it. I don’t receive and error, and I have checked the code gets called, however, it will not delete the file and won’t give an error.
System.IO.File.Delete(target + fupMYfile.FileName);
I did try making sure that IIS_IUSRS has full access to the folder, so I know that is not an issue.
Anybody have any ideas?
thanks
You are not using the same file name. You are saving it something like
c:\somefolder\somefile.xls, then you try to delete it atc:\somefoldersomefile.xls.Use
Path.Compbineto put the folder namd and the file name together: