Click here to Skip to main content
15,887,444 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello
i have a problem with download file in asp.net.
i have a folder in my project and contains many jpg files,when click on a button i want to download a file.
how i can create the path of file with fileinfo?i dont want the path be "c:\1.jpg"
but it is "~/uploads/1.jpg" then fileinfo can not find the file.
any idea?
any solution?
thank you.
Posted
Comments
Sergey Alexandrovich Kryukov 16-Feb-14 17:16pm    
What are even talking about? What path, what file info? Forget about c:\*; there are no such paths accessible by a Web application. The question makes no sense. The download is way to usual operation; I'm just afraid you are not ready to get it as you have some impossible misconceptions; you cannot even explain the "problem".
—SA
When you say it can't find the file, what exception it is throwing?

 
Share this answer
 
Comments
Hajish R I 22-Apr-15 15:59pm    
Thanks
JoCodes 22-Apr-15 16:06pm    
welcome
You can get the path by using the folllowing code


C#
string cvFilePath = Server.MapPath("~/uploads/1.jpg");
FileInfo fiCv = new FileInfo(cvFilePath);
 
Share this answer
 
Comments
Maciej Los 17-Feb-14 18:24pm    
+5
Just for the record: to download a file, you can use either System.Net.WebClient or System.Net.HttpWebRequest (for more flexibility):
http://msdn.microsoft.com/en-us/library/system.net.webclient%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest%28v=vs.110%29.aspx[^].

Please read this documentation; everything is simple.

But please see my comment to the question. Your "difficulties" are absolutely unclear and probably even unrelated to the downloading "problem".

—SA
 
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