如何使用代码下载txt文件 [英] How to downlload txt file using code

查看:100
本文介绍了如何使用代码下载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[^]


这篇关于如何使用代码下载txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆