Issue to access a shared folder from Wince

Hello,

I am working on a colibri T20 running wince7. I develop asoftware (c# application using .NET compact framework 3.5 ) that have to access a folder shared on my network to write some files. But every time I try to connect to my remote folder I recieve an error 59( =unexpected network error ) from the method WNetAddConnection3.

I am running the following code:

    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [MTAThread]
        static void Main()
        {
            Console.WriteLine("coucou");

            IntPtr _handle = IntPtr.Zero;
            
                NETRESOURCE myNetResource = new NETRESOURCE();
                myNetResource.dwScope = 0;
                myNetResource.dwType = (uint)ResourceType.RESOURCETYPE_DISK;
                myNetResource.dwDisplayType = 0;
                myNetResource.dwUsage = 0;
                myNetResource.lpComment = null;
                myNetResource.lpLocalName = "Archiver_Share";
                myNetResource.lpRemoteName = "\\\\remotePC\\sharedF";
                myNetResource.lpProvider = null;

                int result = WNetAddConnection3(_handle, ref myNetResource, "password", "login", 1);

        }

        [DllImport("coredll.dll", EntryPoint = "WNetAddConnection3", CharSet = CharSet.Unicode, SetLastError = true)]
        private static extern int WNetAddConnection3(IntPtr hWndOwner, ref NETRESOURCE lpNetResource, string lpPassword, string lpUsername, int dwFlags);


        [StructLayout(LayoutKind.Sequential)]
        internal struct NETRESOURCE
        {
            public uint dwScope;
            public uint dwType;
            public uint dwDisplayType;
            public uint dwUsage;
            [MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
            public string lpLocalName;
            [MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
            public string lpRemoteName;
            [MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
            public string lpComment;
            [MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
            public string lpProvider;
        }
        public enum ResourceType
        {
            RESOURCETYPE_ANY,
            RESOURCETYPE_DISK,
            RESOURCETYPE_PRINT,
            RESOURCETYPE_RESERVED
        }
    }

Note that I can ping the remote computer that share the folder (with the command ping remotePC) But I cannot access the sharing from the file explorer at the address “\remotePC\sharedF”

Have anyone already met this kind of error? If yes what can I do to connect properly my device?

Best regards,
eiffonck

Error code 59 (“unexpected network error”) typically indicates that there is an issue with the network connection, rather than with the code you are using to connect to the remote folder.

Here are a few things you can try to troubleshoot the issue:

  1. Make sure the remote computer is turned on and connected to the network. If the computer is turned off or not connected to the network, you won’t be able to access the shared folder.
  2. Check that the shared folder is properly configured on the remote computer. Make sure the folder is shared and that the proper permissions are set to allow the user account you are using to access the folder.
  3. Try using the IP address of the remote computer instead of the computer name in the lpRemoteName parameter. This will help you determine whether the issue is related to DNS resolution.
  4. Check the network settings on your device to make sure it is properly configured to connect to the network. Make sure the network settings match the settings of other devices on the same network.
  5. Try temporarily disabling any firewalls or antivirus software on both the device and the remote computer to see if they are interfering with the connection.
  6. Check the Event Viewer on the remote computer to see if there are any relevant error messages that could help diagnose the issue.

Hello,

On your computer in features switch on SMB 1.0/CIFS File Sharing Support.
Try.

Hi @eiffonck & @Kamil277 ,

We are in the process to release a replacement SMB Client & Server that will fully support SMB 3.0, so you don’t need to limit SMB to 1.0 on the remote machine.
This product will be a collaboration between Toradex and Visuality Systems.
See:

Hello,

This very nice information. Thanks