使用asp.net下载文件 [英] Download files using asp.net
问题描述
有一个数据文件和一些图像文件,我必须每天晚上使用asp.net下载到我们的本地服务器。这样做最好的方法是什么?
更新
使用asp.net的帖子是一个糟糕的选择。你如何在C#中为控制台应用程序编写它。我不知道我正在使用什么类别连接和从远程服务器中下载文件。
谢谢
你如何在C#中为控制台应用程序编写它。
创建一个C#控制台应用程序。添加对System.Net的引用。
using System;
使用System.Net;
命名空间下载器
{
类程序
{
public static void Main(string [] args)
{
using (WebClient wc = new WebClient())
{
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屋!