放100分!!!如何把一个事先写好的test.txt文件通过文件读写功能比如FileStream读出来输出到一个变量ii中?

msadmin 2004-07-30 01:56:05
如何把一个事先写好的test.txt文件通过文件读写功能比如FileStream读出来输出到一个变量ii中?这段代码怎么写啊


因为我要在
ss+="</table>"; *********将这个变量连接到ss中去,test.txt里面是一个CSS表



******因为我要把连接后的ss写进testfox.html里面
string path = @"e:\fox\testfox.html";
using(StreamWriter Sw = new StreamWriter(path,false,Encoding.GetEncoding("UTF-8")))
{
Sw.Write(ss);
...全文
224 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
mywebcom 2004-08-03
  • 打赏
  • 举报
回复
这样写吧:
ss+="</table>"+"<table><tr><td>" + strReader + "</td></tr></table>"
gordenfl 2004-08-03
  • 打赏
  • 举报
回复
FileStream stream1 = new FileStream(filepath, FileMode.Open, FileAccess.Read))

buffer1 = new byte[(stream1.Length)];
stream1.Read(buffer1, 0, buffer1.Length);
wnlovezxm 2004-08-03
  • 打赏
  • 举报
回复
string ss;
using (StreamReader sr = new StreamReader("TestFile.txt"))
{

while (sr.ReadLine()) != null)
{
ss = sr.ReadLine() ;
}
}
msadmin 2004-07-30
  • 打赏
  • 举报
回复
to: mywebcom(我)

你看我把strReader怎么连接到ss上面啊

ss+="</table>"+strReader;*******************你看对吗?
mywebcom 2004-07-30
  • 打赏
  • 举报
回复
StreamReader reader=StreamReader(@"c:\text.txt");
string strReader=reader.ReadToEnd();
reader.Close();

ii += strReader;

调试一下了,怎么样的要求都可以了,
呵呵,狗尾续貂了……
msadmin 2004-07-30
  • 打赏
  • 举报
回复
实际上我现在需要的功能就是读一个test.txt(里面包含着css代码)文件,写进一个变量中


然后我要利用这个变量和另外一个变量SS进行连接
msadmin 2004-07-30
  • 打赏
  • 举报
回复
to:acewang(龍芯*Inside!) 我关键是要把读出的test.txt读到一个变量中。然后和ss+="<tables>"进行连接,你误解我的意思了
msadmin 2004-07-30
  • 打赏
  • 举报
回复
to:xingyulou buffer1和ss怎么连接的呢?
chNET 2004-07-30
  • 打赏
  • 举报
回复

up
acewang 2004-07-30
  • 打赏
  • 举报
回复
StreamReader reader=File.OpenText(@"e:\fox\testfox.html");
string source=reader.ReadToEnd();
reader.Close();
心雨楼 2004-07-30
  • 打赏
  • 举报
回复
FileStream stream1 = new FileStream(filepath, FileMode.Open, FileAccess.Read))

buffer1 = new byte[(stream1.Length)];
stream1.Read(buffer1, 0, buffer1.Length);

数据再buffer1 中
孟子E章 2004-07-30
  • 打赏
  • 举报
回复
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
String line;
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}



StreamReader.ReadToEnd()

110,534

社区成员

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

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

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