如何在asp.net中获取具有全路径的postedfile的文件名

问题描述:

在asp.net网站中,如何获取asp.net中具有完整路径的postedfile的文件名
任何人都可以,请帮助我...

In asp.net website how to get file name of postedfile with fullpath in asp.net
anyone.please help me......

这取决于浏览器.有些浏览器发送了它,有些则没有.由于您无法访问客户端的文件系统,因此不需要它,因此您无法做任何有意义的事情.
This is dependent on the browser. Some browsers sent it, and some do not. As you cannot access the client''s file system, you don''t need it, there''s nothing you can do with it that makes much sense.


You can use javascript to achieve this before submit.

For instance<asp:button onClientClick="document.getElementById('hiddenField1').value = document.getElementById('fileUpload1').value"  ...

Then the path can be retrieved on server side via hiddenField1.Value


如果您正在使用FileUpload Control,那么您可以使用以下代码
HttpPostedFile文件= FileUpload1.PostedFile
字符串StrFileName = file.FileName

注意:StrFileName将存储带有文件完整路径的文件名.........
if you are using FileUpload Control than u can use follwing code
HttpPostedFile file = FileUpload1.PostedFile
String StrFileName = file.FileName

Note: StrFileName will store File Name with full path of file........