| 在C#中上传文件和下载文件的简单示例
					当前位置:点晴教程→知识管理交流
					
					→『 技术文档交流 』
					
				 
 在C#中上传文件和下载文件的简单示例-附源码下载,类似完成FTP的功能,不过本程序还不能算是一个FTP程序,操作方法简单,选择需要上传的文件,再勾选上边的对应操作项即可,下载时候记着选择文件下载的本地路径。 private WebClient MyWebClient=new WebClient(); private void BeginBtn_click(object sender, System.EventArgs e) { 	string URL=textBox1.Text; 	if(radioButton1.Checked==false&&radioButton2.Checked==false) 		MessageBox.Show("Please choose the mode!"); 	else 	{ 		if(radioButton1.Checked==true) 		{ 			try 			{ 				statusBar1.Text="Begin to download"; 				MyWebClient.DownloadFile(URL,textBox2.Text); 				statusBar1.Text="Download Successfully!"; 			} 			catch(WebException ee) 			{MessageBox.Show(ee.Message);} 		} 		if(radioButton2.Checked==true) 		{ 			try 			{ 				statusBar1.Text="Begin to upload"; 				MyWebClient.UploadFile(URL,textBox2.Text); 				statusBar1.Text="Upload Successfully!"; 			} 			catch(WebException ee) 			{MessageBox.Show(ee.Message);} 		} 	} } 该文章在 2021/2/4 12:09:38 编辑过 | 关键字查询 相关文章 正在查询... |