将EXE文件添加到我的网站 [英] Adding EXE file to my Website

查看:129
本文介绍了将EXE文件添加到我的网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好..

我的网站建立在ASP.Net 4.0中.我想在我的网页上添加一个exe,以便人们可以下载它.在本地开发人员PC上,我通过使用简单的锚标记进行了尝试.但是,如果我的网站和exe在ftp服务器上该怎么办.我是否需要任何相同的Web服务.

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.

推荐答案

您好,

如果您有文件服务器,那么大概您可以让人们从外部下载文件,而这种方式"必须有一个地址供人们访问吗?诸如"ftp://myfiloserver.mydomain.com/"之类的东西?那么,为什么不放入直接链接到FTP服务器文件的链接标记("a"标记)呢?例如:

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:

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



这应该可行,我已经在其他站点上看到它了:)

希望这会有所帮助,
Ed



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

Hope this helps,
Ed


不确定,但是您可以尝试使用锚标记,提供可直接访问的文件有效路径,并查看其是否有效.

否则尝试:
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:
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.");
    }
}


这篇关于将EXE文件添加到我的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆