Topic "Cannot upload files using C#"

Author Message
J22

Guest


I guess I did everything as mentioned here http://winscp.net/eng/docs/library_install
"By default it looks for the winscp.exe in the same folder, where the assembly is stored. For that reason, you should extract the package into the same folder, where you have WinSCP installed/extracted. You can also copy all binaries, winscp.exe and winscpnet.dll, into separate folder. "
My code:

Code:
FtpMode mode = passiveMode ? FtpMode.Passive : FtpMode.Active;
                SessionOptions sessionOptions = new SessionOptions
                {
                    Protocol = Protocol.Ftp,
                    HostName = hostname,
                    UserName = ftpUsername,
                    Password = ftpPassword,
                    FtpMode = mode,
                    Timeout = new TimeSpan(0, 5, 0)
                };
                using (Session session = new Session())
                {
                    session.ReconnectTime = new TimeSpan(0, 2, 0);
                    string mainDir = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
                    string logPath = Path.Combine(mainDir, "ftp.log");
                    string xmlLogPath = Path.Combine(mainDir, "ftp.xml");
                    session.DebugLogPath = logPath;
                    session.XmlLogPath = xmlLogPath;
                    session.Open(sessionOptions);


                    TransferOptions transferOptions = new TransferOptions();
                    transferOptions.TransferMode = TransferMode.Binary;

                    TransferOperationResult transferResult;

                    transferResult = session.PutFiles(file, destFileName, false, transferOptions);

                    transferResult.Check();
...


Only when there IS an application WinSCP.exe in the directory, the code doesn't work: there is one of these two errors thrown
1) Configured temporary file D:\Export\ftp.xml already exists
2) Error transferring file 'C:\Windows\TEMP\tmpEC19.tmp'.
Without the app in the directory everyhthing works fine.

Thanks in advance for help.
J22

Guest


Solved. The firewall blocked the transfer
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License