从服务器上删除文件:对路径的访问被拒绝 [英] Delete file from server: Access to the path is denied
问题描述
我调用此函数从我的code-背后:结果
的DeleteFile(使用Server.Mappath(/)+sitemap_index.xml)
公共共享功能的DeleteFile(BYVAL名作为字符串)作为布尔
会删除服务器上的文件
昏暗bResult由于布尔=假
尝试
如果File.Exists(文件名)。然后
'删除文件
File.Delete(文件名)
bResult = TRUE
其他
bResult = TRUE
万一
抓住EX为例外结束Try
返回bResult
结束功能
然后我得到的错误:访问路径E:\\ ZZ \\ wwwroot的\\ sitemap_index.xml'。被拒绝
在自己的其他网站的这种逻辑的伟大工程,但在它不当前站点。我检查了我的Windows Server 2008 R2标准版上的安全设置。
在这里看到我的Windows服务器上我的设置上文件夹的wwwroot:
系统:完全控制结果
NETWORK SERVICE:读+写+读取和放大器;执行+列出文件夹内容结果
IIS_IUSRS:读+写
块引用>由于被其他职位我一直在阅读我尝试添加其他用户群的建议,但我没有ASPNET服务/组我的服务器上。
在以管理员身份(Forms身份验证)登录,我可以点击一个按钮来重新创建sitemap_index.xml和sitemaps.xml结果
用户应该能够删除和添加图片到的wwwroot \\影像\\文件夹上传哪一组,我应该给什么权限,以允许上述是可能的,安全吗?
解决方案检查应用程序池用户的访问。
找到您的网站使用的应用程序池,右键单击它并选择
的用户名高级设置...
。该池是利用被旁边列出的身份
。请注意,如果身份说:ApplicationPoolIdentity,你应该检查用户
IIS程序池\\&LT访问;名称这里的应用程序池的制造>
有关ApplicationPoolIdentity看起来
修改
权限<一个href=\"http://www.techexams.net/forums/server-70-290/19589-ntfs-permission-modify-delete-subfolders-files.html\"相对=nofollow>删除文件必需的。尝试给予网络服务修改
的权限。I call this function from with my code-behind:
DeleteFile(Server.MapPath("/") + "sitemap_index.xml")Public Shared Function DeleteFile(ByVal filename As String) As Boolean 'deletes file from server Dim bResult As Boolean = False Try If File.Exists(filename) Then 'delete file File.Delete(filename) bResult = True Else bResult = True End If Catch ex As Exception End Try Return bResult End Function
I then get the error: Access to the path 'E:\zz\wwwroot\sitemap_index.xml' is denied.
In other sites of myself this logic works great, however on the current site it doesnt. I checked the security settings on my windows server 2008 R2 Standard.
See here the settings I have on my Windows server on folder wwwroot:
SYSTEM: Full Control
NETWORK SERVICE: Read + Write + Read & Execute + List folder contents
IIS_IUSRS: Read + WriteAs was suggested by other posts I've been reading I tried adding other user groups, but I have no ASPNET service/group on my server.
When logged in as administrator (Forms authentication) I can click a button to recreate the sitemap_index.xml and sitemaps.xml
Users should be able to delete and add images to the wwwroot\images\uploads folderWhich group should I give what permissions to allow the above to be possible AND secure?
解决方案Check the access for the Application Pool user.
Find the application pool that your site is using, right click on it and choose
Advanced Settings...
. The name of the user that the pool is using is listed next toIdentity
.Note that if the identity says "ApplicationPoolIdentity", you should check the access for the user
IIS AppPool\<Name of the app pool here>
Info about ApplicationPoolIdentity
It looks like
Modify
permissions are required to delete files. Try granting NetworkServiceModify
permissions.这篇关于从服务器上删除文件:对路径的访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!