简体   繁体   English

找不到文件 'c:\\windows\\system32\\inetsrv\\xxx.xlsx'

[英]Could not find file 'c:\windows\system32\inetsrv\xxx.xlsx'

I have a MVC application that reads and uploads an Excel file and processes that file in the app, everything works fine on my local machine, but as soon as I deploy to the server,I get the following error above.我有一个 MVC 应用程序,它读取和上传一个 Excel 文件并在应用程序中处理该文件,在我的本地机器上一切正常,但是一旦我部署到服务器,我就会收到上面的以下错误。 I have added permissions to the IIS App Pool user to root folder, but as soon as I browse for a file through my app on my local machine, it fails with the above error.我已将 IIS 应用程序池用户的权限添加到根文件夹,但是一旦我通过本地计算机上的应用程序浏览文件,它就会失败并出现上述错误。 If i test it on the deployed server it works fine.如果我在部署的服务器上测试它,它工作正常。 Any idea what this is, I have seen a lot of posts on this, tried the suggestions but no luck.知道这是什么,我看过很多关于此的帖子,尝试了建议但没有运气。 Any ideas, Please see my code below.任何想法,请参阅下面我的代码。

try
{
    if (file.ContentLength > 0)
    {
        var fileName = file.FileName;
        var targetFolder = Server.MapPath("/");
        string targetPath = Path.Combine(targetFolder, fileName);
        file.SaveAs(targetPath);

you should use with tilde symbol(~) to point the root of the application你应该使用波浪号(~)来指向应用程序的根

Server.MapPath("~/"); 

and it's better to use subfolder like (make sure there is that folder)最好使用子文件夹(确保有那个文件夹)

Server.MapPath("~/uploads/")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP零:System.IO.FileNotFoundException:找不到文件'c:\\ windows \\ system32 \\ inetsrv \\ log4net.config' - ASP Zero :System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\log4net.config' File.Move错误-System.IO.FileNotFoundException:找不到文件'c:\\ windows \\ system32 \\ inetsrv - File.Move Error - System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv 访问路径 'c:\windows\system32\inetsrv\config\' 被拒绝 - Access to the path 'c:\windows\system32\inetsrv\config\' is denied 找不到路径“ xxx \\ xxx.xlsx”的一部分 - Could not find a part of the path 'xxx\xxx.xlsx' WebClient下载-“拒绝访问路径'c:\\\\ windows \\\\ system32 \\\\ inetsrv \\\\ MyPrintManager.exe'” - WebClient Download - “Access to the path 'c:\\windows\\system32\\inetsrv\\MyPrintManager.exe' is denied” 收到 DirectoryNotFoundException: c:\\windows\\system32\\inetsrv\\Static_Files 当应用程序移动到实时服务器时 - Received a DirectoryNotFoundException: c:\windows\system32\inetsrv\Static_Files When application was moved to a live server 如何使用c#asp.net获取C:\\ Windows \\ System32 \\ inetsrv \\ config文件夹的访问控制 - How to get access control of C:\Windows\System32\inetsrv\config folder using c# asp.net 无法从C:\\ Windows \\ System32 \\ inetsrv \\ hwebcore.dll引用hwebcore.dll到visualstudio2013 - Can't able to refer the hwebcore.dll from C:\Windows\System32\inetsrv\hwebcore.dll to visualstudio2013 Windows窗体程序找不到mdb文件(C:\ windows \ system32 \ qbcdb.mdb) - Windows Form program can not find mdb file (C:\windows\system32\qbcdb.mdb) 找不到路径的一部分 'C:\\Windows\\System32\\oobe\\info\\Backgrounds - Could not find a part of the path 'C:\\Windows\\System32\\oobe\\info\\Backgrounds
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM