WinForm 업데이트 파일
1 private System.Threading.Thread thread1;
2
3 public Login()
4 {
5 InitializeComponent();
6
7 }
8
9 private void button2_Click(object sender, EventArgs e)
10 {
11 thread1 = new System.Threading.Thread(new System.Threading.ThreadStart(UploadVserion));
12 thread1.Start();
13 }
14
15
16 private void UploadVserion()
17 {
18 CheckForIllegalCrossThreadCalls = false;
19
20 String url = "http://123.4.5.5/WebApplication/";
21 String[] arr_file = { "1.exe", "1.dll", "1.png", "1.rar", "2.mp3" };
22
23 try
24 {
25
26 foreach (String filename in arr_file)
27 {
28 //DownloadFile("http://localhost:1928/WebServer/downloader/123.rar", @"C:\123.rar", progressBar1, label1);
29
30 String fullpath = url + filename;
31 String savepath = Application.StartupPath +"\\" + filename;
32 this.label3.Text = " :" + filename;
33 DownloadFile(fullpath, savepath, this.progressBar1, label4);
34 }
35
36 this.label3.Text = " ";
37
38 }
39 catch (System.Exception ex)
40 {
41 this.label3.Text = ex.Message ;
42 }
43 }
44
45 /// <summary>
46 /// c#,.net
47 /// </summary>
48 /// <param name="URL"> </param>
49 /// <param name="URL"> </param>
50 /// <param name="Filename"> </param>
51 /// <param name="Prog"> </param>
52 ///
53 private void DownloadFile(string URL, string filename, System.Windows.Forms.ProgressBar prog, System.Windows.Forms.Label label1)
54 {
55 decimal percent = 0;
56 try
57 {
58 System.Net.HttpWebRequest Myrq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(URL);
59 System.Net.HttpWebResponse myrp = (System.Net.HttpWebResponse)Myrq.GetResponse();
60 long totalBytes = myrp.ContentLength;
61 if (prog != null)
62 {
63 prog.Maximum = (int)totalBytes;
64 }
65 System.IO.Stream st = myrp.GetResponseStream();
66 System.IO.Stream so = new System.IO.FileStream(filename, System.IO.FileMode.Create);
67 long totalDownloadedByte = 0;
68 byte[] by = new byte[1024];
69 int osize = st.Read(by, 0, (int)by.Length);
70 while (osize > 0)
71 {
72 totalDownloadedByte = osize + totalDownloadedByte;
73 System.Windows.Forms.Application.DoEvents();
74 so.Write(by, 0, osize);
75 if (prog != null)
76 {
77 prog.Value = (int)totalDownloadedByte;
78 }
79 osize = st.Read(by, 0, (int)by.Length);
80
81 percent = Math.Round((decimal)totalDownloadedByte / (decimal)totalBytes * 100, 2);
82 label4.Text = " " + percent.ToString() + "%";
83 System.Windows.Forms.Application.DoEvents(); // , label1
84 }
85 so.Close();
86 st.Close();
87 }
88 catch (System.Exception ex)
89 {
90 String a = ex.Message;
91 throw;
92 }
93 }
94
95 private void button3_Click(object sender, EventArgs e)
96 {
97 DialogResult result = MessageBox.Show(" ?", " ···", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
98 if (result == DialogResult.OK)
99 {
100 //thread1.Interrupt();
101
102 //this.label4.Text = "1";
103 thread1.Abort();
104 thread1.Join();
105
106 }
107 }
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.