Results 1 to 8 of 8

Thread: FTP huge file list...

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    FTP huge file list...

    I need to scan a list of files on our FTP site, finding ones with dates in between the given range... problem is, there are over 40K files in the location

    this works to get a list of the files,
    Code:
    Dim sftp As FtpWebRequest = FtpWebRequest.Create("ftp://XXX.XX.X.XXX/BDT/")
            sftp.Method = WebRequestMethods.Ftp.ListDirectory
            Application.DoEvents()
            tssl_Status.Text = "Logging In..."
            Application.DoEvents()
            sftp.Credentials = New NetworkCredential("[USERNAME]", "[PASSWORD]")
            sftp.Timeout = -1
            Dim response As FtpWebResponse = sftp.GetResponse
            tssl_Status.Text = "Retreiving File List..."
            Application.DoEvents()
            Dim reader As New StreamReader(response.GetResponseStream)
            Dim str() As String = Split(reader.ReadToEnd, vbNewLine)
    then i have to take each one and do a get file date
    Code:
    Dim FI As FtpWebRequest = FtpWebRequest.Create("ftp://XXX.XX.X.XXX/BDT/" & File)
                        FI.Method = WebRequestMethods.Ftp.GetDateTimestamp
                        FI.Credentials = New NetworkCredential("[USERNAME]", "[PASSWORD]")
                        FI.Timeout = -1
                        response = FI.GetResponse
                        Dim DateMod As DateTime = response.LastModified
                        
                        If DateMod >= startdate And DateMod <= enddate Then
    now, as you can imagine, this is quite slow when checking 44,562 files....

    so, i tried to use

    sftp.Method = WebRequestMethods.Ftp.ListDirectoryDetails

    but it errors whenpulling the response intot the streamreader... if i let it sit a minute, then hit F5 it will finish, but wont work stright through


    SO what do i do? is there a better way?? Any help or tips would be great!!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: FTP huge file list...

    Code looks ok and works ok but then I don't have 40K files in my ftp folders! I'm not sure that the DoEvents are really necessary and you should remember to close (and probably dispose) the StreamReader but otherwise I can't see anything that would explain a problem at this end of the transaction.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: FTP huge file list...

    without the doevents, its not updating the screen often.

    Yeah code works, just wondering if there is another way? can you pull the file list in chunks?

    ive put in a request to move older files to an archive.. but meantime this is bad lol
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: FTP huge file list...

    without the doevents, its not updating the screen often.
    What is there to update?

    can you pull the file list in chunks?
    Not that I know of. ftp hasn't really changed much since its inception. It's still a rather rudimentary way of doing things so long time processing is kinda expected. I think I'd make that archive request a demand ... with menaces!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: FTP huge file list...

    Quote Originally Posted by dunfiddlin View Post
    What is there to update?
    The label that displays what it's doing...

    AT any rate... have you thought about tossing this into a BackGroundWorker (BGW)? Then it can basically run in the background w/o typing up the front end... would allow you to get rid of the DoEvents, and might free up the front end so that it doesn't appear to take so long.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: FTP huge file list...

    i would have ZERO clue how to due that... never tried it
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: FTP huge file list...

    The label that displays what it's doing...
    Well, not really, as the two status messages are transmitted before the actual ftp process begins. They didn't need any help in doing so when I tried it.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  8. #8

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: FTP huge file list...

    :P ok, i shuffled stuff around and THAT doevents stayed... there are a few of them. (not seen).. sheesh! lol
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width