Click here to Skip to main content
15,846,144 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello..

I have my web site built in ASP.Net 4.0. I want to add an exe to my web page, so that people can download it. at local dev PC I tried it by using simple anchor tag. But what to do if my website and exe is on my ftp server. Do I need any web service for the same.
Posted
Comments
sagar wasule 16-May-12 2:31am    
You can add set up project to ur website

Hi there,

If you have a file server, presumably you have a way for people to download files from it externally, and that "way" must have an address for people to access through? Something like "ftp://myfiloserver.mydomain.com/" or something? So why not just put in a link tag (an "a" tag) that links directly to the FTP server file. For example:

HTML
<a href="ftp://myfiloserver.mydomain.com/A Folder/My EXE file.exe">My EXE File</a>


This should work, I've seen it done on other sites :)

Hope this helps,
Ed
 
Share this answer
 
Comments
comred 16-May-12 7:11am    
thanks..
Not sure but you can try in anchor tag, give a valid path of the file from where it is directly accessible and see if it works.

Or else try:
C#
string filename = "yourfilename";  // file on your server, relative or virtual path to the corresponding physical directory on the server. 
if (filename != "")
{
    string path = Server.MapPath(filename);
    System.IO.FileInfo file = new System.IO.FileInfo(path);
    if (file.Exists)
    {
         Response.Clear();
         Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
         Response.AddHeader("Content-Length", file.Length.ToString());
         Response.ContentType = "application/octet-stream";
         Response.WriteFile(file.FullName);
         Response.End();
    }
    else
    {
         Response.Write("This file does not exist.");
    }
}
 
Share this answer
 
Comments
comred 16-May-12 7:12am    
Thanks
Sandeep Mewara 16-May-12 12:45pm    
Welcome.

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