Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Guest

Hi, Martin!
Thanks for the help, I took a closer look at the log file from SessionLogPath and found the problem.
Although I'm in the line options.HostName = store.IpForFiles; I set the host for the connection - it happens on a different ip.
Solved the problem with this
lock (session.SessionLogPath)
{
    options.HostName = store.IpForFiles;
    session.Open (options);
}

Now everything works out correctly.
martin

Re: c# transfer files in parallel

Show us your SessionFileTransferProgress, and add some logging to it. And show us an overall console output of your code.
Komatozzz

c# transfer files in parallel

Hello ewary one.
I have a problem with transfer files in parallel. When i do that - this look all ok, but indeed nope. If i start one task - File's transfer worked OK, but if i try do more then 1 session in parallel - session.FileTransferProgress in all Task return 100%, but File's loads in not all session in fact. What wrong i do?
PS Without parallel - all works fine.
await Task.Run(() => Parallel.ForEach(storeList, store =>
    {
        if (store.CheckBox == true)
        {
            parallel_options.CancellationToken.ThrowIfCancellationRequested();
 
            using (Session session = new Session())
            {
                options.HostName = store.IpForFiles;
                session.Timeout = TimeSpan.FromSeconds(10);
                session.FileTransferProgress += SessionFileTransferProgress;
                session.Open(options);
                Console.Write("\n" + store.Num + " START!");
                try
                {
                    foreach (var path in FilesList)
                    {
                        bool fileExists = session.FileExists("test_for_upload/");
                        if (fileExists == true)
                        {
                            var transferResult = session.PutFiles(path.PathFile, remoutePath);
                            Console.Write("\n" + store.Num + " EXISTS");
                        }
                        else
                        {
                            session.CreateDirectory("test_for_upload/");
                            var transferResult = session.PutFiles(path.PathFile, remoutePath);
                            Console.Write("\n" + store.Num + " CREATER");
                        }
                    }
                    Console.Write("\n" + store.Num + " FINISH!");
                    session.Close();
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }
                finally
                {
 
                }
 
            }
        }
        else
        {
 
        }
 
    }));