This project is read-only.

Upload limit

Mar 9, 2015 at 3:41 PM
Is there any limit to upload files by
SftpClient client.UploadFile(FileStream, string newPath) method?

Because my program always stopped when reach 1024/XXXX files (label6.Text)
where XXXX is count of files ready to upload and displaying proper value
try { 
            
            string filesFrom = @"PATH_WITH_PDF_FILES";
            string filesTo = @"DESTINATION_PATH";

            string[] filePaths = Directory.GetFiles(filesFrom, "*.pdf");
            int filesUploaded = 0;

            foreach (string plik in filePaths) {
                string newfile=filesTo+plik.Substring(plik.LastIndexOf("\\")+1);

                FileStream ms = new FileStream(filesFrom + plik.Substring(plik.LastIndexOf("\\") + 1), FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite);
                ms.Position = 0;

                mySFTPClient.UploadFile(ms, newfile);

                
                try
                {
                    mySFTPClient.OpenRead(newfile);
                    filesUploaded++;
                    label6.Text = "files:\n" + filesUploaded + "/" + filePaths.Count();
                }
                catch { 
                }

            
            }
            
            MessageBox.Show("DONE");
}
catch
{
            string tresc = "Connected ?";
            MessageBox.Show(tresc);
}
Apr 20, 2015 at 5:54 PM
I can't say about whether or not there is a limit on SSH, but in looking at your code,do you think you could be consuming too many filehandles in your process?

You might want to use ProcessExplorer or some such to see if the filehandle resources are getting freed up?