Tag: download

在Web浏览器中禁止保存/对话框并自动下载

我想通过客户端的链接自动下载exe提示。 我可以从http://go.microsoft.com/fwlink/?LinkID=149156获取第一个重定向链接到http://www.microsoft.com/getsilverlight/handlers/getsilverlight.ashx 。 请单击并检查其工作原理。 fwlink – > .ashx – > .exe …我想获得.exe的直接链接。 但是当通过代码请求Web处理程序时,响应返回404,但如果您尝试使用浏览器,它实际上会下载。 任何人都可以建议如何自动下载上述链接? 我用来获取重定向链接的代码就是这个。 public static string GetLink(string url) { HttpWebRequest httpWebRequest = WebRequest.Create(url) as HttpWebRequest; httpWebRequest.Method = “HEAD”; httpWebRequest.AllowAutoRedirect = false; // httpWebRequest.ContentType = “application/octet-stream”; //httpWebRequest.Headers.Add(“content-disposition”, “attachment; filename=Silverlight.exe”); HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse; if (httpWebResponse.StatusCode == HttpStatusCode.Redirect) { return httpWebResponse.GetResponseHeader(“Location”); } else […]

连接消失时超时。 请帮助我

我想把我的代码暂停一下。 当文件被下载并且我没有上网时,它会计入60秒,如果连接没有返回,则会给出一条消息。 这是代码: string novoNome; novoNome = strlocal + “\\” + zipNome; using (WebClient wcDownload = new WebClient()) { try { if (!Directory.Exists(strlocal)) { Directory.CreateDirectory(strlocal); } #region comunicação para download //string saida; // cria uma requisição do arquivo para download webRequest = (HttpWebRequest)WebRequest.Create(url); webRequest.ReadWriteTimeout = 60000; webResponse = (HttpWebResponse)webRequest.GetResponse(); //Perguntar o tamanho do arquivo Int64 […]

通过Windows 8 Metro XAML App在图片库中下载并保存图像

我正在尝试开发一个简单的Windows 8 Metro应用程序,它只是从给定的URL下载图像文件(比如http://sample.com/foo.jpg ),然后将其保存到图片库。 我在UI中有一个图像控件来显示下载的图像。 我也很难将图像控制的图像源设置为新下载的图像(实际上我甚至无法下载它)。 此外,是否可以将图像文件存储在图片库中的特定文件夹中(如果它不存在,那么应用程序应该创建它)? 我真的被困在这里了。 请帮我。

从FTP上传文件和下载文件

我正在尝试制作一个上传/下载.exe文件到FTP 我尝试使用FtpWebRequest ,但我只能成功上传和下载.txt文件。 然后我在这里找到了一个使用WebClient下载的解决方案: WebClient request = new WebClient(); request.Credentials = new NetworkCredential(“username”, “password”); byte[] fileData = request.DownloadData(“ftp://myFTP.net/”); FileStream file = File.Create(destinatie); file.Write(fileData, 0, fileData.Length); file.Close(); 该解决方案有效。 但我看到WebClient有一个方法DownloadFile没有用。 我认为因为它仅在HTTP上不适用于FTP 。 我的假设是真的吗? 如果没有,我怎么能让它工作? 有没有其他解决方案使用FtpWebRequest上传/下载.exe文件到ftp?