I figured out how to use the OpenFileDialog method. Now I just have to fine tune it.
Hello all,
I have decided not to use outdated code I found on the web and I instead decided to code my own FTP Client.
I created a form with a text box and figured out how to log on and get a listing of my FTP Directory.
It seems very simple but my results are not what I expected. I would like to get a list of the directories (If any) and the files (If any) in root. I seem to be getting that data incorrectly. Also, it appears to be printing my user name and password (Not good).
I would like to adapt the program to use a form of dialog box to get the file I need, but I'm starting out with baby steps.
If you could, would you take a look at my code and my results and offer a suggestion to improve it.
Code ....
Results...
Hello all,
I have decided not to use outdated code I found on the web and I instead decided to code my own FTP Client.
I created a form with a text box and figured out how to log on and get a listing of my FTP Directory.
It seems very simple but my results are not what I expected. I would like to get a list of the directories (If any) and the files (If any) in root. I seem to be getting that data incorrectly. Also, it appears to be printing my user name and password (Not good).
I would like to adapt the program to use a form of dialog box to get the file I need, but I'm starting out with baby steps.
If you could, would you take a look at my code and my results and offer a suggestion to improve it.
Code ....
Code:
Try
Dim MyFTP As FtpWebRequest = FtpWebRequest.Create("ftp://ftp.XXXXXXXX.net")
MyFTP.Credentials = New NetworkCredential("XXXXXXXX", "XXXXXXXX")
MyFTP.Method = WebRequestMethods.Ftp.ListDirectory
Dim sr As New StreamReader(MyFTP.GetResponse().GetResponseStream())
Dim str As String = sr.ReadLine()
While Not str Is Nothing
str = sr.ReadLine()
ftpTextbx1.AppendText(Environment.NewLine & str + vbCr)
End While
sr.Close()
sr = Nothing
MyFTP = Nothing
Catch ex As Exception
Debug.WriteLine(ex.Message & ex.StackTrace)
End Try
Code:
<HTML>
<HEAD>
<TITLE>FTP Listing of Root at ftp.XXXXXXXXs.net</TITLE>
<BASE HREF="ftp://XXXXXXX:XXXXXXXX@ftp.XXXXXXXX.net/">
</HEAD>
<BODY>
<H2>FTP Listing of Root at ftp.XXXXXXXX.net</H2>
<HR>
<PRE>
--------- Welcome to Pure-FTPd [privsep] [TLS] ----------
You are user number 1 of 500 allowed.
Local time is now 11:21. Server port: 21.
This is a private system - No anonymous login
User XXXXXXXX has group access to: 520
</PRE>
<HR>
<PRE>
Aug 09 2012 00:00 Directory <A HREF="BlueIris/">BlueIris</A>
Aug 09 2012 00:00 20 <A HREF="BlueIrisftptest.txt">BlueIrisftptest.txt</A>
Aug 03 2011 00:00 2152886 <A HREF="Cold%20Vengence.rar">Cold Vengence.rar</A>
Mar 05 2009 00:00 1526976 <A HREF="Desktop.zip">Desktop.zip</A>
Mar 05 2009 00:00 176680721 <A HREF="My_Documents.zip">My_Documents.zip</A>
Feb 27 2009 00:00 Directory <A HREF="Pictures/">Pictures</A>
Apr 04 2012 00:00 Directory <A HREF="Software/">Software</A>
May 12 2011 00:00 Directory <A HREF="agoldfarb/">agoldfarb</A>
Feb 27 2009 00:00 Directory <A HREF="aspnet_client/">aspnet_client</A>
May 25 2009 00:00 Directory <A HREF="betty/">betty</A>
Feb 26 2009 00:00 Directory <A HREF="cgi/">cgi</A>
May 12 2011 00:00 Directory <A HREF="edwinech/">edwinech</A>
Feb 27 2009 00:00 0 <A HREF="favicon.ico">favicon.ico</A>
Feb 27 2009 00:00 2471 <A HREF="gdform.asp">gdform.asp</A>
Feb 27 2009 00:00 774 <A HREF="gdform.php">gdform.php</A>
Feb 27 2009 00:00 Directory <A HREF="images/">images</A>
May 12 2011 00:00 1546 <A HREF="missing.html">missing.html</A>
Feb 26 2009 00:00 Directory <A HREF="philmazzola/">philmazzola</A>
Feb 26 2009 00:00 Directory <A HREF="php_uploads/">php_uploads</A>
Feb 27 2009 00:00 Directory <A HREF="pmazzola/">pmazzola</A>
Feb 27 2009 00:00 Directory <A HREF="ronbarnes/">ronbarnes</A>
Aug 14 2009 00:00 30720 <A HREF="snmp.tar">snmp.tar</A>
May 25 2010 00:00 Directory <A HREF="stats/">stats</A>
May 04 2011 00:00 4927 <A HREF="webformmailer.php">webformmailer.php</A>
Feb 27 2009 00:00 2787 <A HREF="welcome.html">welcome.html</A>
</PRE>
<HR>
</BODY>
</HTML>