本帖最后由 chenxiaoguo 于 2009-07-23 10:02:09 编辑

解决方案 »

  1.   

    可以尝试用一下函数实现,要是没权限就用下面的函数setup下,要是有权限的话直接连指定路径就可以了[DllImport("mpr.dll")]
    public static extern int WNetAddConnection2W(
    [MarshalAs(UnmanagedType.LPArray)] NETRESOURCEW[] lpNetResource,
    [MarshalAs(UnmanagedType.LPWStr)] string lpPassword,
    [MarshalAs(UnmanagedType.LPWStr)] string UserName,
    int dwFlags);        [DllImport("mpr.dll")]
            public static extern int WNetCancelConnection2(
                string lpName,
                int dwFlags,
                bool fForce); public static int SetupNetShare(string remotepath, string username, string password)
    {
    NETRESOURCEW [] n = new NETRESOURCEW[1];
    n[0] = new NETRESOURCEW();
    n[0].dwType = 1;
    int dwFlags = 1;
    n[0].lpLocalName = null; 
    n[0].lpRemoteName = remotepath;
    n[0].lpProvider = null;
        
        if (mLog.IsDebugEnabled)
        mLog.Debug(n[0].ToString());
        
    int res = WNetAddConnection2W( n, password, username, dwFlags );
    return res;
    }
    public static int CancleNetShare(string remotepath, int dwFlags, bool fForce)
            {
                int res = WNetCancelConnection2(remotepath, dwFlags, fForce);
                return res;
            }
      

  2.   

    http://hi.baidu.com/freezesoul/blog/item/1ab4d42aa672eb2ed42af119.html
      

  3.   

    http://support.microsoft.com/default.aspx?scid=KB;en-us;q306158