This article describes the method of C#.net to download files from the internet in Winform. Share it for your reference. The details are as follows:
I made a general software automatic upgrade program myself, where I need to download files from the given url to the local area and share them.
/// <summary> /// Download the file/// </summary> /// <param name="URL">Download file address</param>/// <param name="Filename">Save as (full path) after downloading</param>private bool DownloadFile(string URL, string filename) { try { Myrq = ()(URL); myrp = ()(); st = (); so = new (filename, ); byte[] by = new byte[1024]; int osize = (by, 0, (int)); while (osize > 0) { (by, 0, osize); osize = (by, 0, (int)); } (); (); (); (); return true; } catch ( e) { writeLogFile(, true); return false; } }
I hope this article will be helpful to everyone's C# programming.