I have a asp.net page with the following on the page:

<asp:FileUpLoad id="FileUpLoad1" runat="server" /><br />

but i need to get the pathname in that textbox to use with a stored procedure. Now the only thing i can get is the filename (not the path). Any ideas?

This is my code retrieving the filename:

string filename = FileUpLoad1.FileName.ToString();
            //string filepath = FileUpLoad1.;
            Label1.Text = filepath + filename;
            //DataAccess.UploadFlatFile(filepath , filename);


Edited 7 Years Ago by phoenix_dwarf: n/a

just use:

string filepath = System.IO.Path.GetFullPath(FileUpLoad1.FileName);


Alternatively you can use:


remember to mark the thread as solved if you have found an answer :)

Edited 7 Years Ago by Geekitygeek: n/a

this still doesnt work, as it only returns this

C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\upload1.txt

Well basically that all i have:

string filepath = "\'" + System.IO.Path.GetFullPath(FileUpLoad1.FileName)

The thing is in the FileUpload1 textbox it shows the correct path but when put in lable with above code it shows:
C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\upload1.txt

so i don't know why it's doing that?

have you tried it with the code i posted?
I made a simple page with a FileUpload, a button and a label,
when i click the button it runs Label1.Text = Fileupload1.PostedFile.FileName; and it displays the full path and filename correctly.

All i get in the lable is : upload1.txt..... not the full path(if i run your code)...weird!

This article has been dead for over six months. Start a new discussion instead.