Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FTP Example Question
Message
De
03/05/2010 12:08:51
 
 
À
03/05/2010 08:41:26
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01462731
Message ID:
01462818
Vues:
37
I hear what you're saying but I'm not sure I agree. For just learning the basics of C# console apps aren't a bad idea - no WinForms or WPF infrastructure to worry about - just a simple clean Main()..

But maybe it's just a carry-over from the old C++ - firing up a Windows Forms app just to test a bit of code wasn't so simple then :-}

>This is as good a place as any to get off on a rant about one of my primary peeves about .NET training and examples - the console app! In real life there are no console apps !! <s>
>
>Dropping out of the windows environment to run something that looks like it was created in edlin in DOS 2.0 is just silly.
>
>Surely messageboxes, redirection to the output window, pretty much anything that didn't involve popping up a silly black screen would hew closer to the kind of app people are actually trying to write.
>
>Were I writing training material the first thing on my agenda would be to write a simple harness app that would accept the output and display it in the Windows envrironment.
>
>/set rant off
>
>>>I'm lookoing at this example on MSDN on how to FTP download a file. I don't see where the file is downloaded to...
>>>
>>>This is the page and the code
>>>http://msdn.microsoft.com/en-us/library/ms229711(VS.90).aspx
>>>
>>>using System;
>>>using System.IO;
>>>using System.Net;
>>>using System.Text;
>>>
>>>namespace Examples.System.Net
>>>{
>>>    public class WebRequestGetExample
>>>    {
>>>        public static void Main ()
>>>        {
>>>            // Get the object used to communicate with the server.
>>>            FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
>>>            request.Method = WebRequestMethods.Ftp.DownloadFile;
>>>
>>>            // This example assumes the FTP site uses anonymous logon.
>>>            request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");
>>>
>>>            FtpWebResponse response = (FtpWebResponse)request.GetResponse();
>>>    
>>>            Stream responseStream = response.GetResponseStream();
>>>            StreamReader reader = new StreamReader(responseStream);
>>>            Console.WriteLine(reader.ReadToEnd());
>>>
>>>            Console.WriteLine("Download Complete, status {0}", response.StatusDescription);
>>>    
>>>            reader.Close();
>>>            response.Close();  
>>>        }
>>>    }
>>>}
>>
>>To the console :-}
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform