示例
[Visual Basic, C#, C++] 下面的示例将文件从 http://www.contoso.com 下载到本地硬盘。[Visual Basic]
Dim remoteUri As String = "http://www.contoso.com/library/homepage/images/"
Dim fileName As String = "ms-banner.gif"
Dim myStringWebResource As String = Nothing
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
' Concatenate the domain with the Web resource filename. Because DownloadFile
'requires a fully qualified resource name, concatenate the domain with the Web resource file name.
myStringWebResource = remoteUri + fileName
Console.WriteLine("Downloading File ""{0}"" from ""{1}"" ......." + ControlChars.Cr + ControlChars.Cr, fileName, myStringWebResource)
' The DownloadFile() method downloads the Web resource and saves it into the current file-system folder.
myWebClient.DownloadFile(myStringWebResource, fileName)
Console.WriteLine("Successfully Downloaded file ""{0}"" from ""{1}""", fileName, myStringWebResource)
Console.WriteLine((ControlChars.Cr + "Downloaded file saved in the following file system folder:" + ControlChars.Cr + ControlChars.Tab + Application.StartupPath))[C#]
string remoteUri = "http://www.contoso.com/library/homepage/images/";
string fileName = "ms-banner.gif", myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
myStringWebResource = remoteUri + fileName;
Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(myStringWebResource,fileName);
Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);[C++]
String* remoteUri = S"http://www.contoso.com/library/homepage/images/";
String* fileName = S"ms-banner.gif", * myStringWebResource = 0;
// Create a new WebClient instance.
WebClient* myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
myStringWebResource = String::Concat(remoteUri, fileName);
Console::WriteLine(S"Downloading File \" {0}\" from \" {1}\" .......\n\n", fileName, myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
myWebClient->DownloadFile(myStringWebResource, fileName);
Console::WriteLine(S"Successfully Downloaded File \" {0}\" from \" {1}\"", fileName, myStringWebResource);
Console::WriteLine(S"\nDownloaded file saved in the following file system folder:\n\t {0}", Application::StartupPath);[JScript] 没有可用于 JScript 的示例。若要查看 Visual Basic、C# 或 C++ 示例,请单击页左上角的“语言筛选器”按钮 。
[Visual Basic, C#, C++] 下面的示例将文件从 http://www.contoso.com 下载到本地硬盘。[Visual Basic]
Dim remoteUri As String = "http://www.contoso.com/library/homepage/images/"
Dim fileName As String = "ms-banner.gif"
Dim myStringWebResource As String = Nothing
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
' Concatenate the domain with the Web resource filename. Because DownloadFile
'requires a fully qualified resource name, concatenate the domain with the Web resource file name.
myStringWebResource = remoteUri + fileName
Console.WriteLine("Downloading File ""{0}"" from ""{1}"" ......." + ControlChars.Cr + ControlChars.Cr, fileName, myStringWebResource)
' The DownloadFile() method downloads the Web resource and saves it into the current file-system folder.
myWebClient.DownloadFile(myStringWebResource, fileName)
Console.WriteLine("Successfully Downloaded file ""{0}"" from ""{1}""", fileName, myStringWebResource)
Console.WriteLine((ControlChars.Cr + "Downloaded file saved in the following file system folder:" + ControlChars.Cr + ControlChars.Tab + Application.StartupPath))[C#]
string remoteUri = "http://www.contoso.com/library/homepage/images/";
string fileName = "ms-banner.gif", myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
myStringWebResource = remoteUri + fileName;
Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(myStringWebResource,fileName);
Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);[C++]
String* remoteUri = S"http://www.contoso.com/library/homepage/images/";
String* fileName = S"ms-banner.gif", * myStringWebResource = 0;
// Create a new WebClient instance.
WebClient* myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
myStringWebResource = String::Concat(remoteUri, fileName);
Console::WriteLine(S"Downloading File \" {0}\" from \" {1}\" .......\n\n", fileName, myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
myWebClient->DownloadFile(myStringWebResource, fileName);
Console::WriteLine(S"Successfully Downloaded File \" {0}\" from \" {1}\"", fileName, myStringWebResource);
Console::WriteLine(S"\nDownloaded file saved in the following file system folder:\n\t {0}", Application::StartupPath);[JScript] 没有可用于 JScript 的示例。若要查看 Visual Basic、C# 或 C++ 示例,请单击页左上角的“语言筛选器”按钮 。
解决方案 »
- 救命啊!登录验证用户名连接SQL数据库搞了我几天 头大了
- 怎样控制数据绑定控件的数据操作?
- 关于设置网页页面高度问题
- 数据库和页面查询用时不一样求高手
- SqlHelper.dll 哪位大大有,能连同使用方法一起发给我吗,谢谢
- 求助:提交按钮不能用了
- 急:水晶报表错误:fail to get specifical page
- 为什么InitializeComponent()方法中的事件委托代码总被自动删除?
- 微信公众平台测试账号,高级群发接口调用后提示成功,但微信用户并未收到消息
- N久没发贴子了,祝大家十一快乐,玩的开心,顺便问一下大家十一怎么过呀?:)
- 如何关闭网页窗口!
- 请问cookie值使用的问题
imports system.drawing.imaging
............
sub page_load...........................
Dim objbt As Bitmap
Dim objbtnew As Bitmap
objbt = New Bitmap("http://www.123.com/1.jpg
", True)
objbt.Save("c:/1.jpeg",ImageFormat.Jpeg)
strUrl = ""
WebClient wc = new WebClient();
wc.DownloadFile("http://lucky_elove.www1.dotnetplayground.com/Images/logo.gif","c:\\xx.gif");