先调用 net use \\192.168.1.122\share 密码 /User:用户名
然后就像读取本地文件一样的读取了.

解决方案 »

  1.   

    比如用户名为 u ,密码为 p
    用下面语句可以连接远程
    runcmd(@"Net Use \\192.168.1.122\share  p /user:u");
            private static string runcmd(string command)
            {
               Process p = new Process();
               p.StartInfo.FileName = "cmd.exe";           
                p.StartInfo.Arguments = "/c " + command;    
                p.StartInfo.UseShellExecute = false;        
                p.StartInfo.RedirectStandardInput = true;   
                p.StartInfo.RedirectStandardOutput = true;  
                p.StartInfo.RedirectStandardError = true;   
                p.StartInfo.CreateNoWindow = true;          
                p.Start();   
                return p.StandardOutput.ReadToEnd();                }读取文本就像本地一样         string path = @"\\192.168.1.122\share\charp.txt";
            string readText = File.ReadAllText(path);
            Console.WriteLine(readText);
      

  2.   

    下面的两篇文章解决你的问题,
    共享访问在.NET中的实现和应用
    http://blog.csdn.net/zhzuo/archive/2007/08/08/1732937.aspx
    在.NET代码中模拟特定Windows用户
    http://blog.csdn.net/zhzuo/archive/2007/07/18/1698056.aspx