我在使用文件上传获取文件路径时遇到问题.当我测试上传文件上传文件时,我注意到我的文件上传路径错误.正确的路径,C:\RightPath\B1.txt但我检查它是错误的路径,是'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\B1.txt'..
这是我的代码背后......
string OasisPath = Path.GetFullPath(cmdUpload.FileName);
StreamReader OasisFile = new StreamReader(OasisPath);
string B1String = OasisFile.ReadLine();
OasisFile.Close();
Run Code Online (Sandbox Code Playgroud)
我也试过这个..
string OasisPath = Server.MapPath(cmdUpload.FileName);
StreamReader OasisFile = new StreamReader(Server.MapPath(cmdUpload.FileName)); // I get this error Could not find file 'C:\Rightpath\B1.txt'
string B1String = OasisFile.ReadLine();
OasisFile.Close();
Run Code Online (Sandbox Code Playgroud)
请指教我......
谢谢,,