![](/img/trans.png)
[英]ASP Zero :System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\log4net.config'
[英]File.Move Error - System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv
我不知道为什么我会在下面看到这个错误。 我调试时的filevPath是完全有效的(是的,映像的物理位置肯定在传递的filePath变量中的硬盘上),并且显然与错误报告的路径不同,看起来像是通用错误:
System.IO.FileNotFoundException:找不到文件'c:\\ windows \\ system32 \\ inetsrv \\ someimage1.jpg'
private void RenameUploadedFile(string uploadedFileName)
{
string filePath = Path.Combine(WebUtil.UploadPath, uploadedFileName);
if (File.Exists(filePath))
{
try
{
string newfileName = uploadedFileName.Replace(uploadedFileName.Substring(0, uploadedFileName.IndexOf("-")), currenSessionID);
File.Move(uploadedFileName, newfileName);
}
catch (Exception ex)
{
.ErrorLog("Image Copy Error: " + ex.ToString());
throw new ApplicationException("There was an error during a rename(move) operation on the Saved Item upload file: " + filePath + " error: " + ex.ToString());
}
}
else
{
.ErrorLog("File does not exist or path is invalid for at the following filepath: " + filePath);
}
}
更换:
string newfileName = uploadedFileName.Replace(uploadedFileName.Substring(0, uploadedFileName.IndexOf("-")), currenSessionID);
与:
string newfileName = filePath.Replace(filePath.Substring(0, filePath.IndexOf("-")), currenSessionID);
检查该文件夹上的用户权限。
不确定通过查看代码将其放置在何处,但需要使用
Server.GetPath()
查找您的Web应用程序的当前目录。
在ASP.NET中运行时,“ c:\\ windows \\ system32 \\ inetsrv \\”是默认的“当前目录”
如果可以提供有关引发异常时当前与每个文件位置相关的字符串的内容的更多详细信息,我可以告诉您哪个需要调用Server.GetPath()。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.