I have a problem on deleting or moving files after upload in ASP.NET.
I am using RadUpload for uploading files and I want to have a remove button for delete the physical file.
However, right after a successful upload I can't delete the physical file and an error will be raised "File in use".
you should delete it your self by writing the code, and I think you should upload it with your code too. Anyway here is a sample code to delete file.
FileInfo info1 = new FileInfo(folderPath + filename);
if (info1.Exists)
{
info1.Delete();
}
try {
FileInfo TheFile = new FileInfo(MapPath(".") + "\\" + txtFile.Text);
if (TheFile.Exists) {
File.Delete(MapPath(".") + "\\" + txtFile.Text);
}
else {
throw new FileNotFoundException();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.