建立共享文件夹连接
2005-01-05 17:10
281 查看
[StructLayout(LayoutKind.Sequential)] <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
class NETRESOURCE
{
public int dwScope;
public int dwType;
public int dwDisplayType;
public int dwUsage;
public string LocalName = null;
public string RemoteName = null;
public string Comment = null;
public string Provider = null;
}
[DllImport("mpr.dll")]
private static extern int WNetAddConnection2(NETRESOURCE netResource, string password, string username, int flags);
private void EstablishConnection()
{
NETRESOURCE netResource = new NETRESOURCE();
netResource.dwScope = 2;
netResource.dwType = 1;
netResource.dwDisplayType = 3;
netResource.dwUsage = 1;
netResource.RemoteName = @"//192.168.108.18/fbfilestorage";
int ret = WNetAddConnection2(netResource, "password", @"machinename/username", 0); //the ret value in ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/debug/base/system_error_codes.htm
if (ret != 0)
{
throw new Exception(string.Format("Failed to connect the shared folder:{0}", this.workingFolder));
}
}
class NETRESOURCE
{
public int dwScope;
public int dwType;
public int dwDisplayType;
public int dwUsage;
public string LocalName = null;
public string RemoteName = null;
public string Comment = null;
public string Provider = null;
}
[DllImport("mpr.dll")]
private static extern int WNetAddConnection2(NETRESOURCE netResource, string password, string username, int flags);
private void EstablishConnection()
{
NETRESOURCE netResource = new NETRESOURCE();
netResource.dwScope = 2;
netResource.dwType = 1;
netResource.dwDisplayType = 3;
netResource.dwUsage = 1;
netResource.RemoteName = @"//192.168.108.18/fbfilestorage";
int ret = WNetAddConnection2(netResource, "password", @"machinename/username", 0); //the ret value in ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/debug/base/system_error_codes.htm
if (ret != 0)
{
throw new Exception(string.Format("Failed to connect the shared folder:{0}", this.workingFolder));
}
}
相关文章推荐
- 已成功与服务器建立连接,但是在登录过程中发生错误。 (provider: 共享内存提供程序, error: 0 - 管道的另一端上无任何进程。)
- 在window下与linux虚拟机建立共享文件夹
- DC上共享文件夹无法连接
- Ubuntu与WIN7建立共享文件夹
- 在共享文件夹中解压到linux其他目录中,千万注意软连接的问题
- 连接windows2003共享文件夹时需要密码解决方法
- VM下建立共享文件夹
- 【技术贴】解决已成功与服务器建立连接,但是在登录过程中发生错误。 (provider: 共享内存提供
- 在VMware下建立一个linux和Windows共享的文件夹
- SQL2008R2 已成功与服务器建立连接,但是在登录过程中发生错误。 (provider: 共享内存提供程序, error: 0 - 管道的另一端上无任何进程。)
- win10下virtualbox中ubuntu和win10建立共享文件夹的方法
- SQLSERVER:已成功与服务器建立连接 但是在登录过程中发生错误。 provider 共享内存提供程序 error 0 管道的另一端上无任何进程。
- 已成功与服务器建立连接,但是在登录过程中发生错取。(provider:共享内存提供程序,error:0-管道的另一端上无任何进程。)(Microsoft SQL Server,错误:233)
- ubuntu 建立共享文件夹
- Win7下设置远程连接 和 共享文件夹方法
- 已成功与服务器建立连接,但是在登录过程中发生错误。 (provider: 共享内存提供程序, error: 0 - 管道的另一端上无任何进程。)
- 在Windows 7无法通过UNC路径连接到共享文件夹的解决方法
- SQL2008无法连接到.\SQLEXPRESS,用户'sa'登录失败(错误18456)图文解决方法 已成功与服务器建立连接,但是在登录过程中发生错误。 (provider: 共享内存提供程序, er
- ubuntu 建立共享文件夹
- VB建立共享文件夹