文件删除无法在托管上的asp.net vb中运行 [英] File deletion not working in asp.net vb on hosting

查看:71
本文介绍了文件删除无法在托管上的asp.net vb中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



在客户端网站下载后,我在服务器上使用以下代码删除文件。



代码正在从visual studio开始工作,但即使在编码机上托管网站也不行。



Hi All,

I am using following code for file deletion on server after downloading at client site.

The code is working from visual studio but NOT working when website is hosted even on the coding machine.

Dim filefullname As System.IO.FileInfo = New System.IO.FileInfo(theFileName)
                Response.Clear()
                Response.AddHeader("Content-Disposition", "attachment; filename=Observation_Report.docx")
                Response.AddHeader("Content-Length", filefullname.Length.ToString())
                Response.ContentType = "application/octet-stream"
                Response.WriteFile(filefullname.FullName)
                Response.Flush()
                System.IO.File.Delete(theFileName)
                Response.End()

推荐答案

首先,我敢打赌错误会告诉你究竟是什么问题。但是,我敢打赌这是一个权限问题,因为它适用于您的计算机但不能托管。您需要授予承载IIS应用程序池的任何帐户正确的权限,以便从该路径中删除文件。
First off, I'll bet the error tells you exactly what the problem is. However, I'd bet it's a permissions issue since it works on your machine but not hosted. You'll need to grant whatever account is hosting the IIS application pool the proper permissions to delete files from that path.


这篇关于文件删除无法在托管上的asp.net vb中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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