StreamWriter 操作小问题。

HNU 2003-12-04 09:05:28


StreamWriter sw = new StreamWriter(file_path_name);//初始化为一个文件的内容

如何将读到的内容写到一个新文件 ?
...全文
27 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
FileNewExit 2003-12-04
  • 打赏
  • 举报
回复
StreamReader sr = new StreamReader(@"d:\my.txt");
StreamWriter sw = new StreamWriter(@"d:\another.txt");
string s = sr.ReadToEnd();
sr.Close();
sw.Write(s);
sw.Close();

Or use
File.Copy
HNU 2003-12-04
  • 打赏
  • 举报
回复
我的意思是将file_path_name文件中的内容

通过FileSaveDialog保存到例外一个文件中,而不是保存到file_path_name
FileNewExit 2003-12-04
  • 打赏
  • 举报
回复
StreamWriter sw = new StreamWriter(@"d:\my.txt");
sw.Write("Hello");
sw.Close();
HNU 2003-12-04
  • 打赏
  • 举报
回复
sw.Write()多个重载版本我都没看到 Write(string path )参数的啊 ?

比如我想写进 d:\my.txt 如何实现?
FileNewExit 2003-12-04
  • 打赏
  • 举报
回复
sw.Write().........
sw.Close();

111,119

社区成员

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

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

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