Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,
how to get local path of file using file uploader in asp.net, like i browse file D:\\wildlife.flv

I want to get this path using file uploader i tried many thing but it giving me path like D:\\ video application\\wildlife but i want the path like: D:\\ wildlife with out my application folder name.
actually i want to pass path to this command:
C#
_mhandler.CustomCommand = "-i D:\\WildLife.wmv -vf fade=in:1:400 C:\\ConvertedV.wmv";

thanks and regards.

lakhan
Posted
Updated 28-Mar-13 23:01pm
v3
Comments
Hariharan Arunachalam 29-Mar-13 4:59am    
Do you mean to get the client side file path on the server end? I don't think that its possible. You have to save a copy on the server and do the work as necessary.

1 solution

I think This Solution Will Help you...to overcome from your problem...

Server.MapPath("~/Files") returns an absolute path based on a folder relative to your application. The leading ~/ tells ASP.Net to look at the root of your application.

To use a folder outside of the application:

C#
 //check to make sure a file is selected
if (FileUpload1.HasFile)
{
    //create the path to save the file to
    string fileName = Path.Combine(@"E:\Project\Folders", FileUpload1.FileName);
    //save the file to our local path
    FileUpload1.SaveAs(fileName);
}

Of course, you wouldn't hardcode the path in a production application but this should save the file using the absolute path you described.

With regards to locating the file once you have saved it (per comments):

C#
if (FileUpload1.HasFile)
{
    string fileName = Path.Combine(@"E:\Project\Folders", FileUpload1.FileName);
    FileUpload1.SaveAs(fileName);

    FileInfo fileToDownload = new FileInfo( filename ); 

    if (fileToDownload.Exists){ 
        Process.Start(fileToDownload.FullName);
    }
    else { 
        MessageBox("File Not Saved!"); 
        return; 
    }
} 
 
Share this answer
 
v3

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