-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: LovedJohnySmith
Message 2 in Discussion

Hey Raj,   I'm not sure you can achive this in System.Net 1.1(.NET 1.1) but it 
is possible in System.NET 2.0 (.NET 2.0),    In tat, we have WebClient Class, 
from this class you can easily achive your FTP actions. let us say..,   public 
static void Main() {     Stream s = null;     FileStream fs = null;    try      
{            WebClient wc = new WebClient();            byte[] data = 
wc.DownloadData("ftp://localhost/VirtualServer.doc";);           fs = 
File.Create("Download.doc");           fs,Write(data, 0, data.length);      }   
catch(Exception e)    {          Console.WriteLine(e);     }  finally   {     
//CleanUp            if(s!= null) s.Close();           if(fs!=null) fs.Close(); 
   } }   Or If you wanna create professional FTP Client application., You can 
do wif the help of  WebRequest Class. see the following code snippet.   
FtpWebRequest ftpReq = (FtpWebRequest) 
WebRequest.Create(ftp://localhost/VirtualServer.doc); // SET CREDENTIAL - go to 
the user directory ftpReq.Credentials = new NetworkCredential("<domain\user>", 
"<password>");   //SET Proxy ftpReq.Proxy = null; //SET BINARY MODE 
ftpReq.UseBinary = true; //SET Passive Mode ftpReq.UsePassive = true;   //SET 
Method to Download File ftpReq.Method = WebRequestMethods.Ftp.DownloadFile; 
FtpWebResponse ftpRes = (FtpResponse) ftpReq.GetResponse(); s = 
ftpRes.GetResponseStream();   //Copy the Content to Local File fs = 
File.Create("Download.doc"); byte[] bytes = new byte[1000]; int numBytesRead 
=0; while(numBytesRead = s.Read(bytes, 0, bytes.length)) >0) {   
fs.Write(bytes, 0, numBytesRead); }   thanx, Smith   

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to