.NET assembly: one user gets "cannot open file \\.nul\" every time

Advertisement

allen.hunter
Joined:
Posts:
1

.NET assembly: one user gets "cannot open file \\.nul\" every time

Hi there, I have a C# program that logs into a remote SFTP site and synchronizes directories using the .NET assembly 5.19.5

I've tested it with 10 people, and 9 of them had no issues. the tenth gets the error message "cannot open file \\.nul\". I have verified that he can do a synchronize just using winscp.exe himself, so I am hoping that I can fix this.

The code around where the problem seems to start is pretty simple:
string sFileMask = "*|AlfheimLauncher.exe;  WinSCP.exe; WinSCPnet.dll; AlfheimLauncher.pdb; config/; Optional Mods/; cache/; LogOutput.log; patchlogs/;"; // white listed files we ignore
using (Session session = new Session())
{
    session.DebugLogPath = "patchlogs\\patchdebug.txt";
    session.XmlLogPath = "patchlogs\\xmllog.xml";//System.AppDomain.CurrentDomain.BaseDirectory;
    session.SessionLogPath = "patchlogs\\patchlog.txt";
    SessionOptions sessionOptions = GetSCPSessionOptions();
 
    // Will continuously report progress of synchronization
    session.FileTransferred += FileTransferred;
    session.OutputDataReceived += OutputDataReceived;
 
    // Connect
    session.Open(sessionOptions);
 
    // get a count of files to possibly be patched
    TransferOptions tOptions = new TransferOptions();
    // White List
    tOptions.FileMask = sFileMask;
 
    ComparisonDifferenceCollection diffs = session.CompareDirectories(SynchronizationMode.Local, System.AppDomain.CurrentDomain.BaseDirectory, remotePath, true, false, SynchronizationCriteria.Size, tOptions);
    NumberTotalFiles = diffs.Count;
 
    // Synchronize files
    if (NumberTotalFiles > 0)
    {
        AnnounceProgress(0, NumberTotalFiles, "Updating Files...");
        foreach(ComparisonDifference diff in diffs)
        {
            diff.Resolve(session, tOptions);
        }
    }
sessionOptions are broken out into their own function, which I will include here just so you have the complete context:
// we keep our credentials in their own function for ease of maintenance
protected SessionOptions GetSCPSessionOptions()
{
    SessionOptions sessionOptions = new SessionOptions
    {
        //This account has read-only access to the latest game files, and no permissions beyond that
        Protocol = Protocol.Sftp,
        HostName = ConfigurationManager.AppSettings.Get("HostName"),
        UserName = ConfigurationManager.AppSettings.Get("UserName"),
        Password = ConfigurationManager.AppSettings.Get("PassWord"),
        SshHostKeyFingerprint = ConfigurationManager.AppSettings.Get("SshHostKeyFingerprint"),
    };
    return sessionOptions;
}
In the process of debugging this, I configured the executable to generate a DebugLogPath and a SessionLogPath. Interestingly, the executable only generated the DebugLogPath file for the troubled user (it generated both with me just fine). You can also see that I set the XmlLogPath to a directory that my application created, just to ensure that this wasn't a permissions issue.

I can provide a debug log of it working fine if that is helpful. I am attaching the problem debuglog.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
36,712
Location:
Prague, Czechia

Re: .NET assembly: one user gets "cannot open file \\.nul\" every time

If you execute a command like this on that machine, do you get the same error?
"winscp.exe" /xmllog="xmllog.xml" /xmlgroups /xmllogrequired /nointeractiveinput /ini=nul /log="patchlog.txt" /console

Reply with quote

Advertisement

You can post new topics in this forum