ASP.NET中如何在内存中操作一个文本文件? (50分立即给)

4221dotcom 2004-08-06 03:47:24
ASP.NET中如何在内存中操作一个文本文件?

网页制作中,需要生成一个文本文件,存放在内存中,如: csdn.txt
可以向该文本文件写入新的文本信息,如:csdn.
在需要时,可以调用该文本文件,以获取存放在其中的信息.
...全文
136 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
benbencatrabbit 2004-09-08
  • 打赏
  • 举报
回复
xue xi
coollzh 2004-09-08
  • 打赏
  • 举报
回复
需求不清楚哦,把细节说一下,否则答非所问,要讲究点提问技巧
yyxx8 2004-09-07
  • 打赏
  • 举报
回复
奇怪地设计模式必然导致奇怪地细节
coollzh 2004-09-06
  • 打赏
  • 举报
回复
不需要写文件,用个全局静态变量来保存就可以了,
该变量可以放在Global.asax.cs中
public static StringBuilder buffer = new StringBuilder ()

用的时候
Global.buffer.Append("content");
zilang 2004-09-06
  • 打赏
  • 举报
回复
不知道这些奇怪的想法都用在什么地方
ctrl2 2004-09-06
  • 打赏
  • 举报
回复
MemoryStream ReturnStream = new MemoryStream();

//Create a streamwriter to write to the memory stream
StreamWriter WriteStream = new StreamWriter(ReturnStream,System.Text.Encoding.GetEncoding("GB2312"));

//Write the text in the textbox to the Memory Stream.
WriteStream.WriteLine("写入的内容");
saucer 2004-09-06
  • 打赏
  • 举报
回复
>>>需要生成一个文本文件,存放在内存中????

yes, you can use MemoryStream, but you have to work on bytes and convert from/to string, I would suggest you use a String or StringBuilder in the Session variable

StringBuilder sb = new StringBuilder();
Session["MyVar"] = sb;

StringBuilder s2 = (StringBuilder)Session["MyVar"];
...

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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