Bajar archivos con c#

Páginas: 2 (496 palabras) Publicado: 4 de abril de 2011
In this tutorial you will know how to download a file from a web site and upload a file to a web site through c# project. The System.Net namespace contain most of the .NET base class that deal withnetworking from perspective of the client. The System.Net namespace is generally concerned with Higher-level operations for example download and upload files and making requests using the HTTP andother protocols. The WebClient ClassIf you want to do is carry out a fairly simple operation such as requesting a file from a particular URL, Then you will probably find easiest .NET class to use isSystem.Net.WebClient. This class is extremely high-level class Designed to perform basic operations with only one or two commands Downloading Fiels:There are two ways of downloading a file from a web siteusing WebClient, depending on whether we want to save the file, or process the contents of the directly within your application. If we simply want to save the file then we should call theDownloadFile() method takes two parameters, The URL from where we want to retrieve the file, and the file name ( or path) that we want to save the file to.
WebClient Client = new WebClient ();Client.DownloadFile("http://www.csharpfriends.com/Members/index.aspx", " index.aspx"); |
More commonly, your application will want to process the data retrieved from the web site. In order to do this, you use theOpenRead () method, Which returns a stream reference. You can then simply retrieve the data from the stream.
WebClient Client = new WebClient (); Stream strm = Client.OpenRead("http://www.csharpfriends.com/Members/index.aspx"); |
The following code will demonstrate the WebClient.OpenRead () method.In this case we will simply display the contents of the downloaded data in list box.Wecreate the project as standard Windows C# application, and a list box called listbox1, in which we will display the contents of the downloaded file. We make the following changes to the constructor of...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Bajar archivos
  • Bajar Archivo
  • Archivos c#
  • Archivos En C++
  • Archivos en c++
  • Manejo De Archivos A Bajo Nivel En C
  • c++ archivos
  • Archivo en c

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS