Posts

Showing posts with the label File

Download File using Dot Net

In this post, I will demonstrate how easy it is to download a file from a web server to your local hard drive. In most scenarios, you may browse the net using your web browser and click on a hyperlink to start a downloading of a file from a remote site. Some of you may be interested in how to download this using their application code using Dot Net. This can be very easily achieved using the WebClient class under System.Net namespace. First, import the System.Net namespace. using System.IO; The above LOC will do so. Now, create an instance of WebCleient class. WebClient client = new WebClient(); Now, call the DownloadFile method client.DownloadFile(<url>, @"<fileDestinationName>.<filetype>"); Have fun. Cheers !!!!

Dot Net Writing to a File

A very simple LOC which may become very useful. File.WriteAllText("C:\\a.txt","Hello World");