нормально я загрузке файла с сервера, и я планирую, чтобы удалить файл, который я скачал на сервере после того, как он получает загружены на стороне клиента ..загрузить файл с сервера, а затем удалить на сервере
Мой код загрузки работает нормально, но я не знаю, когда нужно поместить команду для удаления файла.
string filepath = restoredFilename.ToString();
// Create New instance of FileInfo class to get the properties of the file being downloaded
FileInfo myfile = new FileInfo(filepath);
// Checking if file exists
if (myfile.Exists)
{
// Clear the content of the response
Response.ClearContent();
// Add the file name and attachment, which will force the open/cancel/save dialog box to show, to the header
Response.AddHeader("Content-Disposition", "attachment; filename=" + myfile.Name);
//Response.AddHeader("Content-Disposition", "inline; filename=" + myfile.Name);
// Add the file size into the response header
Response.AddHeader("Content-Length", myfile.Length.ToString());
// Set the ContentType
Response.ContentType = ReturnExtension(myfile.Extension.ToLower());
//// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
Response.TransmitFile(myfile.FullName);
// End the response
Response.End();
}
Теперь я знаю response.end() остановит каждую вещь и вернуть значение, так есть и другой способ тоже сделать так ..
мне нужно вызвать функцию
DeleteRestoredFileForGUI (restoreFilename);
, чтобы удалить файл, но не знаете, куда положить его .. я пытался ставить перед и после Response.End(), но он не работает ..
любая помощь приветствуется ... спасибо
Будет ли работать этот код. И вместо выполнения response.end() работает response.redirect ("~/page-for-delete.aspx? File = delete.dat", false); - добавив false, вы продолжаете обрабатывать информацию на этой странице. – Kieran
@Kieran, TransmitFile завершает ответ на передачу файла и Response.Redirect приведет к конфликту с ответом. –