现在需要将一行一行的文本写入到dat文件,每写一行要换行,要写入的数据是从数据库取出的,
dat文件时自己生成的,还请帮忙,最好有code,谢谢!
dat文件时自己生成的,还请帮忙,最好有code,谢谢!
解决方案 »
- wpf 中用代码可以把arm格式的音频文件转为MP3格式吗?如果可以请贴出代码 谢谢
- 求教线程问题!!!急!~
- 该用户与可信任的 SQL SEVER 无关联
- 直接上传文件到带有frontpage扩展的IIS服务器上!
- 请教UltraWebListbar第二次调用页面时不能刷新的问题
- 如果做到自动下载ActiveX,并且自动安装呢?
- 2003 .net框架下如何运行asp程序
- WebForm中使用对话框
- 制作安装文件的时候,能否得到当前IIS的主目录?或者怎样得到用户在输入虚拟目录和端口的时候的那个虚拟目录名称?谢谢!
- 关于winform中一段程序看不懂,求解释
- 寻求一个解决方案
- C#编译的问题,求高手解惑
System.IO.StreamWriter sw = null;
try
{
sw = new System.IO.StreamWriter(@"d:\data.dat", true);
for (int i = 0; i < 10; i++)
{
sw.WriteLine(String.Format("Item {0}.", i));
}
sw.Flush();
}
catch (Exception ex)
{
throw ex;
}
finally
{ sw.Close();
sw.Dispose();
}
File.WriteAllLines
StreamWriter
//生成批处理文件用于重启程序
string bat=Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"update.bat");
if (File.Exists(bat))
File.Delete(bat);
using(StreamWriter sw=new StreamWriter(bat,true))
{
sw.WriteLine("@echo off");
sw.WriteLine(":find");
FileInfo appexe = new FileInfo(Application.ExecutablePath);
sw.WriteLine(string.Format("tasklist|find \"{0}\" ||goto next", appexe.Name));
sw.WriteLine("goto find");
sw.WriteLine(":next");
foreach (string name in okfiles)
{
sw.WriteLine(string.Format("copy update\\{0} {1} /y",name,name));
}
sw.WriteLine("start "+Application.ExecutablePath);
sw.WriteLine("del %0");
sw.WriteLine("exit");
}
System.Diagnostics.Process.Start(bat);
Environment.Exit(0);