Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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:
   _mhandler.CustomCommand = "-i D:\\WildLife.wmv -vf fade=in:1:400 C:\\ConvertedV.wmv"; 
thanks and regards.
 
lakhan
Posted 28-Mar-13 21:47pm
Edited 29-Mar-13 0:01am
v3
Comments
Hariharan Arunachalam at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:
 
 //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):
 
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; 
    }
} 
  Permalink  
v3

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



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100