asp.net - “/”应用程序中的服务器错误。找不到路径的一部分
问题描述
我正在尝试在单击按钮时删除 XML 文件,这些文件位于我网站上的 XML 文件夹中(在 smarterasp.net 托管中),使用以下代码:
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button4.Click
Dim directoryName As String = MapPath("~/xml/")
For Each deleteFile In Directory.GetFiles(directoryName, "*.xml", SearchOption.TopDirectoryOnly)
File.Delete(deleteFile)
Next
Label1.Text = "done"
End Sub
但我收到了这个错误:
Server Error in '/' Application.
Could not find a part of the path 'C:\Windows\SysWOW64\inetsrv\karary-001-
site1.htempurl.com\xml'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a
part of the path 'C:\Windows\SysWOW64\inetsrv\karary-001-
site1.htempurl.com\xml'.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[DirectoryNotFoundException: Could not find a part of the path
'C:\Windows\SysWOW64\inetsrv\karary-001-site1.htempurl.com\xml'.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +219
System.IO.FileSystemEnumerableIterator`1.CommonInit() +268
System.IO.FileSystemEnumerableIterator`1..ctor(String path, String
originalUserPath, String searchPattern, SearchOption searchOption,
SearchResultHandler`1 resultHandler, Boolean checkHost) +434
System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption
searchOption) +86
WebApplication1.addTimetable.Button4_Click(Object sender, EventArgs e) in
C:\Users\MONZER\Desktop\Karary Web
Site\WebApplication1\addTimetable.aspx.vb:65
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9815014
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
+204
获取文件夹的正确方法是什么,我已经尝试过:
1- http://karary-001-site1.htempurl.com/xml/
2- h:\root\home\karary-001\www\site1\xml\
3- ~/xml/
解决方案
推荐阅读
- c# - C# 单元测试复杂的多线程数据库读取
- ethereum - web3 发送数据和令牌
- jquery - 如果(垂直)滚动条在另一个 div 中可见,则向 div 添加填充
- javascript - 如何使用 GET 方法向 URL 添加警报提示以从 URL 获取数据
- javascript - javascript - replace() 删除字符串中所有重复的字母
- serial-port - 如何在扭曲的串行控制线上生成事件
- traffic - 如何让firefox通过mitmproxy连接网页?
- javascript - PhpStorm:YUI Compressor JS 不适用于打字稿
- python - 如何在 Python 中使用 praw 将保存的 reddit 帖子列表抓取到 txt 文件
- python - 如何获取“src=...”的 url?