|
-
Sep 17th, 2013, 07:54 AM
#1
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"
-
Sep 17th, 2013, 09:21 AM
#2
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!
-
Sep 17th, 2013, 10:08 AM
#3
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"
-
Sep 17th, 2013, 10:40 AM
#4
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!
-
Sep 17th, 2013, 11:53 AM
#5
Re: FTP huge file list...
 Originally Posted by dunfiddlin
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
-
Sep 17th, 2013, 12:14 PM
#6
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"
-
Sep 17th, 2013, 12:18 PM
#7
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!
-
Sep 17th, 2013, 12:32 PM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|