我收到此错误无法找到文件'C:\program files(x86)\ IIS express\uploadfile'。 [英] I am getting this error could not find file 'C:\program files (x86)\IIS express\uploadfile'.

查看:196
本文介绍了我收到此错误无法找到文件'C:\program files(x86)\ IIS express\uploadfile'。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 var oldFileTxt = Server.MapPath(@txtp1.Text); 
var newFileTxt = Server.MapPath(@txtp2.Text);我已经使用了这段代码并在阅读文件路径时收到错误。





我尝试了什么:



而不是server.path我使用过File.Readline但得到了同样的错误。我希望这是动态的。请建议

解决方案

假设文件位于您网站的根目录中 - 这是一个不好的主意 - 您需要在文件名前加上〜 - 如果不这样做,则假定它在与页面ASPX文件相同的文件夹:

 string oldFileTxt = Server.MapPath(@〜/ txtp1.Text); 

更好的主意是专门为文件创建一个文件夹并使用它:

 string oldFileTxt = Server.MapPath(@〜/ Uploads / txtp1.Text); 


var oldFileTxt = Server.MapPath(@"txtp1.Text");
var newFileTxt = Server.MapPath(@"txtp2.Text"); i have used this code and getting error while reading the path of the file.



What I have tried:

instead of server.path i have used File.Readline but getting the same error .i want this to be dynamic .please suggest

解决方案

Assuming the file is in the root directory of your website - which is a poor idea - you need to prefix the filename with a "~" - if you don't it's assumed to be in the same folder as the page ASPX file:

string oldFileTxt = Server.MapPath(@"~/txtp1.Text");

A better idea is to create a folder specifically for files and use that:

string oldFileTxt = Server.MapPath(@"~/Uploads/txtp1.Text");


这篇关于我收到此错误无法找到文件'C:\program files(x86)\ IIS express\uploadfile'。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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