troubleshooting Question

Problem with FTP using VB.Net

Avatar of collages
collagesFlag for United States of America asked on
Visual Basic.NET
4 Comments1 Solution803 ViewsLast Modified:
I am using the FTP code found here:

http://www.codeproject.com/vb/net/FtpClient.asp

I am trying to download files from an FTP and store them on a network drive.  I can use the following code successfully to download a single file:

Dim myFtp As New FTPclient("192.168.1.200", "jhaft", "alp123ha")
        Dim fullList As FTPdirectory = myFtp.ListDirectoryDetail("")
        Dim filesOnly As FTPdirectory = fullList.GetFiles() 'fullList.GetFiles()
        myFtp.Download("/test1.xls", "M:\Corporate\Finance\Corporate Finance\FDM4 Reports\To Process" + "\test1.xls")


But what I really need to is download every .XLS file.  So, I'm trying this but it doesnt work:

Sub Main()
        Dim myFtp As New FTPclient("192.168.1.200", "jhaft", "password")
        Dim fullList As FTPdirectory = myFtp.ListDirectoryDetail("")
        Dim filesOnly As FTPdirectory = fullList.GetFiles() '
        For Each file As FTPfileInfo In myFtp.ListDirectoryDetail.GetFiles
            ' If Not file.Filename Like "*xls*" Then GoTo SkipFile
            myFtp.Download(file.Filename, "M:\Corporate\Finance\Corporate Finance\FDM4 Reports\To Process\" + file.Filename)
            'SkipFile:
        Next file

The problem has to do with the was I am setting the filename...i get a "PathTooLongException" and when I look at the filename I am setting it comes back as:

M:\Corporate\Finance\Corporate Finance\FDM4 Reports\To Process\.profile-rw-r-----   1 jhaft    staff         13824 Jul 27 14:46 test2.xls-rw-r-----   1 jhaft    staff          1317 Jul 27 12:04 test3.xls-rw-r-----   1 jhaft    staff         13824 Jul 27 14:46 test4.xls

What am I doing wrong here?

Or, is there another way I could do this?


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros