.Net Assembly SCP download to Windows always stops after476 mb

Advertisement

sameh
Joined:
Posts:
1

.Net Assembly SCP download to Windows always stops after476 mb

When trying to download a large file from my SCP server it always stops at 476 MB. I tried
sessionOptions.AddRawSettings("SendBuf", "0");
sessionOptions.AddRawSettings("SshSimple ", "0");
But still can't do it. Here is my code:
try
{
    // Setup session options
    SessionOptions sessionOptions = new SessionOptions
    {
        Protocol = Protocol.Scp,
        HostName = "192.168.10.1",
        UserName = "******",
        Password = "******",
        SshHostKeyPolicy = SshHostKeyPolicy.GiveUpSecurityAndAcceptAny
    };
    
    // Connect to the remote server and download files
    using (Session session = new Session())
    {
        session.ReconnectTime = TimeSpan.FromSeconds(2);
        sessionOptions.AddRawSettings("SendBuf", "0");
        sessionOptions.AddRawSettings("SshSimple ", "0");
 
        session.Open(sessionOptions);
 
        string remotePath = "/mnt/hdd_1/mstore/QLIVE.vfdp/storage/1001_NileSatDocuments_220101010000_250101120000/";
 
        var opts = EnumerationOptions.EnumerateDirectories | EnumerationOptions.AllDirectories;
        IEnumerable<RemoteFileInfo> fileInfos = session.EnumerateRemoteFiles(remotePath, null, opts);
 
        foreach (RemoteFileInfo fileInfo in fileInfos)
        {
            if (fileInfo.IsDirectory)
            {
                continue; // skip directories
            }
 
            // Determine local and remote file paths
            string remoteFilePath = RemotePath.EscapeFileMask(fileInfo.FullName);
            string localFilePath = RemotePath.TranslateRemotePathToLocal(remoteFilePath, remotePath, Path.GetTempPath());
 
            // Download the file to the temporary folder
            System.Diagnostics.Debug.WriteLine("Downloading file {0}...", fileInfo.FullName);
            TransferOperationResult transferResult = session.GetFiles(remoteFilePath, localFilePath);
 
            // Check if download succeeded
            if (!transferResult.IsSuccess)
            {
                System.Diagnostics.Debug.WriteLine("Error downloading file {0}: {1}", fileInfo.FullName, transferResult.Failures[0].Message);
            }
 
            if (Path.GetExtension(fileInfo.Name) == ".zip")
            {
                using (ZipFile zip = ZipFile.Read(localFilePath))
                {
                    string destinationPath = @"D:\Education - FrontEnd\videos";
                    zip.ExtractAll(destinationPath, ExtractExistingFileAction.OverwriteSilently);
                }
            }
 
            // Determine the final destination path
            string finalFilePath = Path.Combine(@"D:\Education - FrontEnd\videos", fileInfo.Name);
            session.RemoveFiles(remoteFilePath);
        }
 
        session.Close();
    }
}
catch (Exception ex)
{
    // Log any errors
    System.Diagnostics.Debug.WriteLine("Error occurred: " + ex.Message);
}

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,276
Location:
Prague, Czechia

Re: .Net Assembly SCP download to Windows always stops after476 mb

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

Advertisement

You can post new topics in this forum