2
我在使用文件上傳獲取文件路徑時遇到問題。當我測試上傳文件上傳文件時,我注意到我的文件上傳得到了錯誤的路徑。正確的道路是C:\RightPath\B1.txt
但我檢查其得到錯誤的路徑是'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\B1.txt'
..如何在asp中使用fileupload獲取正確的路徑。淨?
這裏是我的背後...代碼
string OasisPath = Path.GetFullPath(cmdUpload.FileName);
StreamReader OasisFile = new StreamReader(OasisPath);
string B1String = OasisFile.ReadLine();
OasisFile.Close();
我也試過這一個..
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();
請諮詢我...
感謝,,
您是否試圖從它來自的計算機獲取文件的完整路徑,或者您是否想知道它在服務器上的位置?出於安全和其他原因,您無法獲取源代碼的路徑。 – DOK 2011-06-03 14:16:14
@DOK,我明白了。是的,我可以找到完整的路徑。我不知道在服務器路徑..對不起.. – ghie 2011-06-03 14:17:29