日期:2014-05-18  浏览次数:20394 次

远程写文件问题
asp.net2.0(vs2005):
主程序(web站点A,192.168.1.10)调用   webservice   (站点B,192.168.1.20)写文本文件到另一台机器(机器C,192.168.1.30)的共享目录“test”下。

webservice   中主要代码如下:
using   (StreamWriter   sw   =   new   StreamWriter(fullFileName,   true,   System.Text.Encoding.GetEncoding( "gb2312 ")))
                                {
                                        sw.Write(text);

                                        sw.Flush();
                                        sw.Close();
                                }
在开发中,几台XP系统测试没问题,部署后,站点A和站点B都是2000server,机器C是2000professional,试过映射磁盘,试过用   System.Diagnostics.Process.Start( "net.exe ",   "use   \\\\ip\\ipc$   \ "1234\ "   /user:\ "administrator\ " ");     方法,都出错,IE中提示:不正确的用户名或错误密码。

另外,用以下代码(已添加引用,编绎没问题):
ConnectionOptions   options   =   new   ConnectionOptions();  
options.Username   =   u;
options.Password   =   p;
ManagementScope   scope   =   new   ManagementScope(path,   options);
scope.Connect();
运行到ManagementScope   scope   =   new   ManagementScope(path,   options);时提示“无效参数”,照着微软的例子做的,超级郁闷!

谁来帮忙啊!

------解决方案--------------------
第一个,检查一下你用站点B的机器直接连机器C,不用程序,看能不能连.再检查一下是不是防火墙的问题.
第二个,检查一下ManagementScope scope = new ManagementScope(path, options);中的path参数值.
------解决方案--------------------
up
------解决方案--------------------
第一个,检查一下你用站点B的机器直接连机器C,不用程序,看能不能连.再检查一下是不是防火墙的问题.
第二个,检查一下ManagementScope scope = new ManagementScope(path, options);中的path参数值.

OK!
------解决方案--------------------
学习 接分
------解决方案--------------------
webservice 是以什么帐号运行的?确认这个帐号(或者使用身份模拟)能在机器C上写共享目录

参考
http://support.microsoft.com/kb/306158/zh-cn