情况是这样,文件在A服务器目录Folder下,用户名User密码Password,已经有Administrator设好,A服务器环境为win2000 server 
现在要从Application服务器B使用用户名密码连接上A服务器的目录Folder,然后下载文件txt,B服务器环境也为win2000 server。使用的语言是C#.net,求高手给解决方案,如有代码小弟感激不尽!!!

解决方案 »

  1.   

    共享方式?你可以通过映射网络驱动器的方式建立连接,然后像访问本地目录一样访问,参看
    http://blog.csdn.net/knight94/archive/2006/03/21/631309.aspx
    http://blog.csdn.net/knight94/archive/2006/03/31/645367.aspx
      

  2.   

    抄别人的代码
    public static void OpenDirectory(string str_Directory,string to_Directory, string str_UserName, string str_Password)
            {
                string str_LogoOn = "net use " + str_Directory + " /user:" + str_UserName + " \"" + str_Password + "\"";
                string str_OpenDirectory = "start " + str_Directory;            Process p_Tmp = new Process();
                p_Tmp.StartInfo.RedirectStandardError = true;
                p_Tmp.StartInfo.RedirectStandardInput = true;
                p_Tmp.StartInfo.RedirectStandardOutput = true;
                p_Tmp.StartInfo.UseShellExecute = false;
                p_Tmp.StartInfo.CreateNoWindow = true;
                p_Tmp.StartInfo.FileName = "cmd.exe";
                p_Tmp.Start();
                p_Tmp.StandardInput.WriteLine(str_LogoOn);
                p_Tmp.StandardInput.WriteLine(str_OpenDirectory);
                p_Tmp.StandardInput.WriteLine("exit");
                p_Tmp.Close();
                p_Tmp.Dispose();            string[] files = Directory.GetFiles(fromDirectory);
                if (files.Length > 0)
                {
                    foreach (string s in files)
                    {
                        FileInfo objFI = new System.IO.FileInfo(s);
                        File.Copy(str_Directory + "\\" + objFI.Name.ToString(), to_Directory + "\\" + objFI.Name.ToString());
                    }
                }
            }
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Runtime.InteropServices;namespace IISWatcher
    {    [StructLayout(LayoutKind.Sequential)]
        public class NetMappingDrive
        {
            private int dwScope;
            private int dwType;
            private int dwDisplayType;
            private int dwUsage;
            private string strLocalName;
            private string strRemoteName;
            private string strComment;
            private string strProvider;
            private string strUsername;
            private string strPassword;        public string LocalDrive
            {
                get { return strLocalName; }
            }        public string NetPath
            {
                get { return strRemoteName; }
            }        public string UserName
            {
                get { return strUsername; }
            }
            public string Password
            {
                get { return strPassword; }
            }        //如果正确,返回值是0;否则错误。
            [DllImport("mpr.dll", EntryPoint = "WNetAddConnection2")]
            private  static extern uint WNetAddConnection2([In] NetMappingDrive lpNetResource, string lpPassword, string lpUsername, uint dwFlags);        [DllImport("Mpr.dll")]
            private static extern uint WNetCancelConnection2(string lpName, uint dwFlags, bool fForce);        public  NetMappingDrive(string LocalDrive, string NetPath,string Username,string Password)
            {
                this.dwScope = 2;
                this.dwType = 1;
                this.dwDisplayType = 3;
                this.dwUsage = 1;
                this.strLocalName = LocalDrive;
                this.strRemoteName = NetPath;
                this.strProvider = null;
                this.strUsername = Username;
                this.strPassword = Password;        }        public uint CreateDrive()
            {
                return WNetAddConnection2(this, this.strPassword, this.strUsername, 0);
            }        public uint DeleteDrive()
            {
                return WNetCancelConnection2(this.strLocalName, 1, true);
            }
        }}影射为网络驱动器然后用fileinfo copy