using System.IO
and use this code
try {
FileInfo TheFile = new FileInfo(MapPath(".") + "\\" + txtFile.Text);
if (TheFile.Exists) {
File.Delete(MapPath(".") + "\\" + txtFile.Text);
}
else {
throw new FileNotFoundException();
}
}
catch (FileNotFoundException ex) {
lblStatus.Text += ex.Message;
}
catch (Exception ex) {
lblStatus.Text += ex.Message;
}
FileInfo TheFile = new FileInfo(MapPath(".") + "\\" + txtFile.Text);
if (TheFile.Exists) {
File.Delete(MapPath(".") + "\\" + txtFile.Text);
}
else {
throw new FileNotFoundException();
}
}
catch (FileNotFoundException ex) {
lblStatus.Text += ex.Message;
}
catch (Exception ex) {
lblStatus.Text += ex.Message;
}
No comments:
Post a Comment