删除文件不起作用 [英] delete file not working

查看:106
本文介绍了删除文件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,用户可以在其中上载图像并将其存储在temp文件夹中以对其进行处理.图像处理完成后,图像下载到用户PC并从temp文件夹中删除.为此,我在下面进行了编码

i have an application in which user upload the image and it stores in temp folder to work on it. When process on image got complete, image downloads to the user pc and delete from the temp folder. For that i have coded below

//upload the image
FileUpload1.SaveAs(Server.MapPath("~/temp/") + FileUpload1.FileName)
 //coading to process on uploaded image
        
//download file
        Me.Response.AddHeader("content-disposition",       String.Format("attachment;filename={0}", Path.GetFileName(FileUpload1.FileName)))
        Me.Response.ContentType = "image/jpg"
        Me.Response.WriteFile(Server.MapPath("~/temp/") + FileUpload1.FileName)

// delete the file from temp
        
File.Delete(Server.MapPath("~/temp/") + FileUpload1.FileName)


现在,当我编写此代码并运行应用程序时,它不会出错,也不会下载或删除文件.这两个功能都可以很好地分开工作,但是当我将下载内容和删除内容放在一起时,我会遇到问题...任何人对此都有任何想法并可以帮助我... ???在此先感谢...


Now, when i write this code, and run the application it is not getting error but also not downloading or deleting the file. This both functions are works fine separatly but when i put download and after delete together i face the problem... can any one have any idea of this and help me out...??? Thanks in advance...

推荐答案

它不能直接从中删除.
直到检查它是否对您有帮助:

Its not directly delete from that .
till just check that it help you :

Response.Flush();
System.IO.File.Delete(fullPathFileName);
Response.[End]();


这篇关于删除文件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆