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