先调用 net use \\192.168.1.122\share 密码 /User:用户名
然后就像读取本地文件一样的读取了.
然后就像读取本地文件一样的读取了.
解决方案 »
- SQL设置主键问题
- 如何把object转换成System.Collections.Generic.KeyValuePair<string, string>类型
- 为什么.css下拉菜单放在.html中就好使而.ascx中就不好使
- 下面是一段数据更新的代码,数据库应该是打开一次关一次,还是打开两次关两次?那种设计更合理一点?
- Oracle连接串的写法,大家帮帮忙
- 关于VSTS的统计使用
- 应许多网友的强烈要求,现公开文华报表集成开发环境的全部近10000行源码!
- 在DataGrid中显示数据库时间时总是2004-1-1 0:00:00 这种格式
- 数据库表的操作
- 请问如何读取硬盘物理序列号,不是逻辑序列号。
- 更新数据库
- 省,市,县,三级联动问题...大虾们进来哈...
用下面语句可以连接远程
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);
共享访问在.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