先使用Wmi开通连接,再靠文件
下面是sdk中的例子。
using System;
using System.Management;// This example demonstrates how to connect to remote machine
// using supplied credentials.
class Sample_ConnectionOptions
{
    public static int Main(string[] args) {
        ConnectionOptions options = new ConnectionOptions();
        options.Username = UserName; //could be in domain\user format
        options.Password = SecurelyStoredPassword;
        ManagementScope scope = new ManagementScope(
            "\\\\servername\\root\\cimv2",
            options);
        try {
            scope.Connect();
            ManagementObject disk = new ManagementObject(
                scope,
                new ManagementPath("Win32_logicaldisk='c:'"),
                null);
            disk.Get();
        }
        catch (Exception e) {
            Console.WriteLine("Failed to connect: " + e.Message);
        }
        return 0;
    }
}

解决方案 »

  1.   

    我是在WEB下,使用IP也不行,权限没有问题。我在本机中进行拷贝没有问题。
      

  2.   

    确保 ASPNET 帐户具有的权限能够访问启动 Aspnet_wp.exe 进程和为 ASP.NET 页提供服务所必需的全部目录和文件。
      

  3.   

    File.Copy("10.85.17.13\D:\eBus_desiger\ebus\Ebus\excel\aaa.txt", Server.MapPath("excel\\aaa.txt"))
    报错:
    不支持给定路径的格式
      

  4.   

    File.Copy("\\10.85.17.13\D:\eBus_desiger\ebus\Ebus\excel\aaa.txt", Server.MapPath("excel\\aaa.txt"))
    试试看
      

  5.   

    我以前写过类似的程序,但是在Winform 程序中写的,具体的方法是:假如:您的本地机子的IP是192.168.1.20,您想拷贝的文件在IP为192.168.1.43机器上D盘下的share文件夹下,您首先要做的是在192.168.1.43机器上共享share文件夹,然后程序中的代码为:
    File.Copy("\\192.168.1.43\share\您的文件名字")  即可。
    因为我在做的时候,是在保证这两台机器是处于能互相访问的前提下,因此这样写可以。
    若要考虑事先没有连通一下两台机器的话,应该首先用一下zhzuo(秋枫)兄台的方法,我现在
    这样认为,因为,我没有环境可以试
      

  6.   

    File.Copy忘了加目的路径参数了,不好意思,请大家自己加上应该就可以吧
      

  7.   

    我也是像你说得那样但是报错说:未能找到文件
    是不是File.Copy只能在win下使用
      

  8.   

    哦!
    I THINK:File.Copy只能运用在Windows下,在别的操作系统中,文件的组织方式与
    Windows中的文件的组织方式都是不一样的!而且,微软现在的.net框架在别的操作系统下没有实现的版本吧!
      

  9.   

    File.Copy("10.85.17.13\D$\eBus_desiger\ebus\Ebus\excel\aaa.txt", Server.MapPath("excel\\aaa.txt"))
      

  10.   

    WIN2003
    public const int LOGON32_LOGON_INTERACTIVE = 2;
    public const int LOGON32_PROVIDER_DEFAULT = 0;WindowsImpersonationContext impersonationContext; [DllImport("advapi32.dll", CharSet=CharSet.Auto)]
    public static extern int LogonUser(String lpszUserName, 
                                      String lpszDomain,
                                      String lpszPassword,
                                      int dwLogonType, 
                                      int dwLogonProvider,
                                      ref IntPtr phToken);
    [DllImport("advapi32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto,
          SetLastError=true)]
    public extern static int DuplicateToken(IntPtr hToken, 
                                      int impersonationLevel,  
                                      ref IntPtr hNewToken);public void Page_Load(Object s, EventArgs e)
    {
       if(impersonateValidUser("username", "domain", "password"))
       {
          //Insert your code that runs under the security context of a specific user here.
          undoImpersonation();
       }
       else
       {
          //Your impersonation failed. Therefore, include a fail-safe mechanism here.
       }
    }private bool impersonateValidUser(String userName, String domain, String password)
    {
       WindowsIdentity tempWindowsIdentity;
       IntPtr token = IntPtr.Zero;
       IntPtr tokenDuplicate = IntPtr.Zero;   if(LogonUser(userName, domain, password, LOGON32_LOGON_INTERACTIVE, 
       LOGON32_PROVIDER_DEFAULT, ref token) != 0)
       {
          if(DuplicateToken(token, 2, ref tokenDuplicate) != 0) 
          {
             tempWindowsIdentity = new WindowsIdentity(tokenDuplicate);
             impersonationContext = tempWindowsIdentity.Impersonate();
             if (impersonationContext != null)
                return true;
             else
                return false; 
          }
          else
             return false;
       } 
       else
          return false;
    }
    private void undoImpersonation()
    {
       impersonationContext.Undo();

    其他
    System.Diagnostics.Process.Start("net.exe","use \\\\10.88.60.98\\d$\\yo \"168168\" /user:\"administrator\"");