[问题]streamwriter不能writer!!

pencil001 2004-05-05 12:35:15
我看了《通过压缩SOAP改善XML Web service性能》后,觉得蛮不错,就想尝试一下,可是在最后运行的时候在下面这个函数遇到问题
private void Compress(SoapMessage message)
{
if(message is SoapServerMessage)
{
newStream.Position = 0;
StreamReader reader = new StreamReader(newStream);
StreamWriter writer = new StreamWriter(oldStream);
string UnCompressedString = reader.ReadToEnd();
string CompressedString = MyZipLib.Zip.Deflate(UnCompressedString);
writer.WriteLine(CompressedString);
writer.Flush();
}
}

主要问题是此时oldStream的类型为System.Web.Services.Protocols.SoapExtensionStream,但是其Length和Position属性都为 error: an exception of type: {System.NotSupportedException} occurred,从而造成字符串根本写不到oldStream中去

我单步调试过,确实是写不进去,请问如何解决?
...全文
173 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
pencil001 2004-05-05
  • 打赏
  • 举报
回复
canwrite属性是true
pencil001 2004-05-05
  • 打赏
  • 举报
回复
应该不是吧,如果是这样soap extension就没有意义了
pencil001 2004-05-05
  • 打赏
  • 举报
回复
如不是单步调试,整个运行后,结果就为The root element is missing
1979xt 2004-05-05
  • 打赏
  • 举报
回复
可能是只读的原因

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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