如何使用代码下载txt文件

如何使用代码下载txt文件

问题描述:


我正在Windows应用程序上工作.如何在按钮单击事件上使用c#代码下载txt文件

谢谢
phoolchand

Hi,
i am working on windows application .How to download txt file using c# code on button click events

Thanks
phoolchand

请参阅如何在C#中简单下载文件. NET [ ^ ].


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);


这可能对您有帮助

http://www.devtoolshed.com/content/c-download-file-progress-bar [ ^ ]
This may help you

http://www.devtoolshed.com/content/c-download-file-progress-bar[^]