How to download certain amount of files?

Advertisement

ferliano001
Guest

How to download certain amount of files?

When I try to download using session.GetFiles(path) everything is fine and I get all 500 files, but in my case I need to download 125 files out of 500, so I made this method, because I didn't find any ready to go method for such operation in docs, maybe I am wrong tho.

So when I use this method it loses some of my files, for example I constantly get only 118 out of 125 (I tried to test it like 10 times with the same result) and I can't understand why, would be great if I am just wrong and there is a better way to do what I need using docs.
int currentFile = 0;
RemoteDirectoryInfo directory=testSes.ListDirectory(cfgTorrentsPath);
foreach (RemoteFileInfo fileInfo in directory.Files) {
      session.GetFiles(path + fileInfo.Name, Directory.GetCurrentDirectory() + @"\folder\"+fileInfo.Name);
      if (currentFile >= 125) {
         break;
      }
      currentFile += 1;
}

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
32,052
Location:
Prague, Czechia

Re: How to download certain amount of files?

You definitely have to skip the . and .., and in general any (sub)directories.
Post a session log file, if you want more details.

Reply with quote

Advertisement

You can post new topics in this forum