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: WinSCP C# Library - Cannot open file “\\.\nul”. Access denied

My guess is that you are trying to use WinSCP .NET assembly with some very old version of WinSCP.exe (and you try to workaround that by setting client.DisableVersionCheck = true).
JulienPlanche

WinSCP C# Library - Cannot open file “\\.\nul”. Access denied

Hello all !
I have a Raspberry Pi with SFTP enabled for one user which is "wifi". When I connect using Filezilla client, it works great. But when I use the WinSCP Library (the latest), it failed with

{WinSCP.SessionRemoteException: Cannot open file "\\.\nul". Accès refusé

   at WinSCP.SessionLogReader.Read(LogReadFlags flags)
   at WinSCP.ElementLogReader.Read(LogReadFlags flags)
   at WinSCP.SessionElementLogReader.Read(LogReadFlags flags)
   at WinSCP.CustomLogReader.TryWaitForNonEmptyElement(String localName, LogReadFlags flags)
   at WinSCP.CustomLogReader.WaitForNonEmptyElement(String localName, LogReadFlags flags)
   at WinSCP.Session.WaitForGroup()
   at WinSCP.Session.Open(SessionOptions sessionOptions)
   at DumboNetwork.Controllers.SFTP..ctor(String args)}

Here is the code used

sessionOptions = new SessionOptions

            {
                Protocol = Protocol.Sftp,
                HostName = args,
                UserName = "wifi",
                Password = "password",
                SshHostKeyFingerprint = "ssh-rsa 2048 6c:53:02:91:9f:08:3d:a1:d3:45:e5:67:8a:88:f8:14",
                GiveUpSecurityAndAcceptAnySshHostKey = true,
                PortNumber = 22,
            };
            client = new Session();
            client.SessionLogPath = ApplicationData.Current.LocalFolder.Path + "\\" + "debug.log";
            client.DisableVersionCheck = true;

            int attempts = 0;
            do
            {
                try
                {
                    client.Open(sessionOptions);
                }
                catch (Exception e)
                {
                    attempts++;
                    Debug.WriteLine(e);
                }
            } while (attempts < _connectionRetryAttempts && !client.Opened);

Can you help me ? Thanks !