Topic "Help required with logging and files not being posted.\"

Author Message
sharoz
[View user's profile]

Joined: 2016-07-11
Posts: 3
Hi,

i am using below code for transferring files to WinSCP. "SourcePath" are the directories,"SourcePathRecordings" are the files contained in those directories and there are almost 100 files in each directory. The issue i have been encountering is

1. sometimes the files doesn't get posted, if there are 100 files in the directory only 40-50 get posted although i have the loop on each file.
2. I want to enable WINSCP logging, and i want the log file to save on the local system. how would i do that?

Urgent help will be highly appreciated! Rolling Eyes

for (int a = 0; a < SourcePath.Length; a++)
{
string[] SourcePathRecordings = Directory.GetFiles(SourcePath[a]);
for (int i = 0; i < SourcePathRecordings.Length; i++)
{
string CommandText = "";
CommandText += @"/command ""option batch abort"" ""option confirm off"" ""Open """"" + SFTPAddress;
CommandText += @""""" -passive=on"" ""Put """"" + SourcePathRecordings[i];
CommandText += @""""" """"" + TargetPath + @"""""";
CommandText += @""" ""close"" ""exit"" ";
Process winscp = new Process();
winscp.StartInfo.FileName = @"C:\WinSCP3\WinSCP.exe"
winscp.StartInfo.Arguments = CommandText;
winscp.StartInfo.UseShellExecute = false;
winscp.StartInfo.RedirectStandardInput = true;
winscp.StartInfo.RedirectStandardOutput = true;
winscp.StartInfo.CreateNoWindow = true;
winscp.StartInfo.ErrorDialog = true;
winscp.WaitForExit();
winscp.Close();
c++;
}
}
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
To enable logging, use /log=c:\path\winscp.log command-line parameter.

Though I highly recommend you to use WinSCP .NET assembly, instead of trying to run winscp.exe yourself.
sharoz
[View user's profile]

Joined: 2016-07-11
Posts: 3
i tried using the assembly too but the issue remains same if there are 75 files in my folder and i post them one by one only 10-15 files gets posted.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
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.
sharoz
[View user's profile]

Joined: 2016-07-11
Posts: 3
Martin,

i am trying to copy files over the network through winscp. I am using the assembly as per your advice. there are 100 folders on my root directory and each folder contains 100-150 files. i have attached the session log, I am getting connection time outs for all my session. Could you please help me with this?
winsp08.12.2016.log (25.98 KB) Private file

Description: Session Log

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Sorry, I have no idea why the server keeps disconnecting you. It looks like a server-side bug.
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