使用asp.net下载文件 [英] Download files using asp.net

查看:120
本文介绍了使用asp.net下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个数据文件和我使用asp.net下载到本地服务器每天晚上一些图像文件。什么是做到这一点的最好方法是什么?

更新

好了,看的答复后,我看到使用asp.net我最初的职位是一个糟糕的选择。你会如何​​写在C#中的控制台应用程序。我不知道我正在使用哪些类连接并从远程服务器拉下来的文件。

感谢

解决方案
  
    

你会如何写在C#中的控制台应用程序。

  

创建一个C#控制台应用程序。添加引用System.Net。

 
使用系统;
使用System.Net;

命名空间下载
{
    类节目
    {
    公共静态无效的主要(字串[] args)
    {
    使用(WebClient的WC =新的Web客户端())
    {
    wc.DownloadFile(http://www.mydomain.com/resource.img,C:\\ savedImage.img);
    }
    }
    }
}
 

There is a data file and some image files that I have to download to our local servers every night using asp.net. What is the best way to do this?

UPDATE

Ok, after viewing the responses I see my initial post of using asp.net is a poor choice. How would you write it for a console app in C#. I am not sure what classes I am using to connect and pull down files from the remote server.

Thanks

解决方案

"How would you write it for a console app in C#."

Create a C# console application. Add a reference to System.Net.


using System;
using System.Net;

namespace Downloader
{
    class Program
    {
    	public static void Main(string[] args)
    	{
    		using (WebClient wc = new WebClient())
    		{
    			wc.DownloadFile("http://www.mydomain.com/resource.img", "c:\\savedImage.img");
    		}
    	}
    }
}

这篇关于使用asp.net下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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