如何在asp.net中获取上载文件的地址

问题描述:

我需要我刚刚通过asp.net中的文件上传控件上传的文件的实际位置.我尝试使用

i need the actual location of the file that i have just uploaded via a file upload control in asp.net. i''ve tried using

string fileName = Path.GetFullPath(fUpldGetDoc.PostedFile.FileName);


但这会返回


but this returns

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\angel from montegomery.txt



但我需要文件的实际位置,即



but i need the actual location of the file i.e,

e:\angel from montegomery.txt

您可以使用javascript

http://forums.asp.net/t/1077850.aspx/1 [ ^ ]


还讨论了其他几种方法,希望对这些方法有用.
You can do by a javascript

http://forums.asp.net/t/1077850.aspx/1[^]


few other methods are also discussed and hope useful


使用System.io;

using System.io;

FileInfo f = New FileInfo(Server.MapPath(".") + "\" + uploadedfilename);

       String fileName = f.FullName;


string fileName = fUpldGetDoc.PostedFile.FileName;



试试这个



try this