Post a reply

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

martin

Re: Dir Sync: WinSCP.SessionRemoteException for remote path

sebastian.hockmann wrote:

I can access this path on the production machine.

Can you access it even as CORP\AS-ESB-01T$?
sebastian.hockmann

Dir Sync: WinSCP.SessionRemoteException for remote path

Hello.

i would like to mirror / sync a FTP directory to a local path.
I'm using the current version of the .NET library.

This works fine on my developer machine. But on the production machine
i get the following error:

WinSCP.SessionRemoteException: Error retrieving file list for "\\group.jenoptik.corp\Global\OS\OES\PS\Triptis\Files\PRODUKTION\AVT\Projekte\CMOSIS\01_ARF\

I can access this path on the production machine.

I attached the logs (debug+session)

Any ideas for the root cause ?

Thanks,
Sebastian

P.D:


Here is my C# coding:

public class FTPSync
{
public int syncronizeDirectory( string hostname, string username, string password, string localpath, string remotepath)
{

//set connection parameters
WinSCP.SessionOptions sessionOptions = new SessionOptions();
sessionOptions.Protocol = WinSCP.Protocol.Ftp;
sessionOptions.HostName = hostname; //"as-ftp-e01.jenoptik.corp";
sessionOptions.UserName = username; //"JOPS-CMOSIS";
sessionOptions.Password = password; //"1234";
sessionOptions.FtpMode = FtpMode.Passive;

//

WinSCP.Session session = new Session();
session.DebugLogPath = @"d:\debuglog.txt";
session.SessionLogPath = @"d:\sessionlog.txt";
session.

try
{

using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"d:\auth.txt"))
{
string svc_username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
file.WriteLine(svc_username);
}

//change user context
using (new Impersonator ("service.wmistest","CORP","1234"))
{

//log user context
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"d:\auth.txt"))
{
string svc_username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
file.WriteLine(svc_username);
}

session.FileTransferred += FileTransferred;
// Connect
session.Open(sessionOptions);

string localpath = @"\\group.jenoptik.corp\Global\OS\OES\PS\Triptis\Files\PRODUKTION\AVT\Projekte\CMOSIS\01_ARF";
string remotepath = "01_ARF";

// Synchronize files to local directory, collect results
SynchronizationResult synchronizationResult;
synchronizationResult =
session.SynchronizeDirectories(
WinSCP.SynchronizationMode.Local, localpath, remotepath, false);

//throw on any error
synchronizationResult.Check();

return 0;

}
}




catch (Exception e)
{
Console.WriteLine("Error: {0}", e);
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"d:\error.txt"))
{
file.WriteLine(e);
}

//errormessage = e.Message;
return -1;
}

}

private static void FileTransferred(object sender, TransferEventArgs e)
{
if (e.Error == null)
{
Console.WriteLine("Upload of {0} succeeded", e.FileName);
}
else
{
Console.WriteLine("Upload of {0} failed: {1}", e.FileName, e.Error);
}

if (e.Chmod != null)
{
if (e.Chmod.Error == null)
{
Console.WriteLine("Permisions of {0} set to {1}", e.Chmod.FileName, e.Chmod.FilePermissions);
}
else
{
Console.WriteLine("Setting permissions of {0} failed: {1}", e.Chmod.FileName, e.Chmod.Error);
}
}
else
{
Console.WriteLine("Permissions of {0} kept with their defaults", e.Destination);
}

if (e.Touch != null)
{
if (e.Touch.Error == null)
{
Console.WriteLine("Timestamp of {0} set to {1}", e.Touch.FileName, e.Touch.LastWriteTime);
}
else
{
Console.WriteLine("Setting timestamp of {0} failed: {1}", e.Touch.FileName, e.Touch.Error);
}
}
else
{
// This should never happen with Session.SynchronizeDirectories
Console.WriteLine("Timestamp of {0} kept with its default (current time)", e.Destination);
}
}
}
}