webservice客户端推送数据到服务器端

billy001001 2013-12-16 08:59:10
服务器端:
public void PushMeasurementService(string str)
{
string s = str;

string filePath = "..\\test.txt";
FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs);
fs.SetLength(0);
sw.Write(s);
sw.Close();

}
客户端:
ServiceReference1.Service1SoapClient a = new ServiceReference1.Service1SoapClient();
string s = "test";
a.PushMeasurementService(s);

就是想把客户端的数据,存到服务器端的text.txt文本中。是web.config文件要改什么权限吗?

错误:
其他信息: System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 ---> System.UnauthorizedAccessException: 对路径“c:\windows\system32\test.txt”的访问被拒绝。
在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
在 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
在 QDDMS.Service1.PushMeasurementService(String str) 位置 D:\work\QDDMS\QDDMS\Service1.asmx.cs:行号 39
--- 内部异常堆栈跟踪的结尾 ---
...全文
498 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
billy001001 2013-12-17
  • 打赏
  • 举报
回复
已经解决,把文件名的绝对路径加上就好了
风一样的大叔 2013-12-16
  • 打赏
  • 举报
回复

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧