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);

:-/

Re: How do I get the path name of FileUpload contol in asp.net (C#) 80 80

any suggestions will be much appreciated

Re: How do I get the path name of FileUpload contol in asp.net (C#) 80 80

just use:

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

:icon_mrgreen:

Re: How do I get the path name of FileUpload contol in asp.net (C#) 80 80

just use:

string filepath = System.IO.Path.GetFullPath(FileUpLoad1.FileName);
Re: How do I get the path name of FileUpload contol in asp.net (C#) 80 80

Alternatively you can use:

Fileupload1.PostedFile.FileName;

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

Re: How do I get the path name of FileUpload contol in asp.net (C#) 80 80

this still doesnt work, as it only returns this

C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\upload1.txt
Re: How do I get the path name of FileUpload contol in asp.net (C#) 80 80

instead of the actual path where it was on the client side....

Re: How do I get the path name of FileUpload contol in asp.net (C#) 80 80

works perfetly for me : /
Can you post the rest of the code you used when trying it?

Re: How do I get the path name of FileUpload contol in asp.net (C#) 80 80

which code would you need? lol as not being specific doesnt help me on what code to paste

Re: How do I get the path name of FileUpload contol in asp.net (C#) 80 80

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?

Re: How do I get the path name of FileUpload contol in asp.net (C#) 80 80

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.

Re: How do I get the path name of FileUpload contol in asp.net (C#) 80 80

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

Re: How do I get the path name of FileUpload contol in asp.net (C#) 80 80

It works only on old browser IE. Latest browsers do not reveal full path for security reasons. However, I'm sure there is a way out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.