Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I'm using fileupload control and I want to know the location that comes in the fileupload control. But I can only get the filename

For example, my file may be in C:/myfolder/hi.txt. If I upload this file, I want this location, but instead I'm getting only the file name hi.txt
C#
string filename1 = Path.GetFileName(FileUpload1.FileName);
string ls_nm = HiddenField1.Value;
string path = Path.GetDirectoryName(FileUpload1.PostedFile.FileName);
string toatal = FileUpload1.PostedFile.FileName;


All these methods returns only that filename , how to get exact location??

Thanks in Advance
Posted
Updated 11-Apr-11 20:17pm
v3
Comments
Eduard Keilholz 12-Apr-11 2:17am    
Added 'codeproject friendly formatting' ;)

 
Share this answer
 
v3
have a look to the link click here

It should help you.
 
Share this answer
 
This has been asked a number of times here before.

All these methods returns only that filename
why FileUpload Control Doesn’t Give Full Path[^]
 
Share this answer
 
By using the following code you can do that,-
string filePath = FileUpload1.PostedFile.FileName;
 
Share this answer
 
string filePath = FileUpload1.PostedFile.FileName;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900