private void button1_Click(object sender, EventArgs e)
{
string path = "";
if(folderBrowserDialog1.ShowDialog()==DialogResult.OK)
{
folderBrowserDialog1.ShowNewFolderButton = true;
path=folderBrowserDialog1.SelectedPath;
FileStream aFile = new FileStream("Log.txt", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(aFile); bool truth = true;
// Write data to file.
sw.WriteLine("Hello to you.");
sw.WriteLine("It is now {0} and things are looking good.",
DateTime.Now.ToLongDateString());
sw.Write("More than that,");
sw.Write(" it's {0} that C# is fun.", truth);
sw.Close();
}
}先创建一个文件夹。
然后创建一个txt文件,Log.txt,想把该文件放在创建的那个文件夹中,可是系统默认放在文件夹debug中,怎么办啊!
高手们,请赐教,我是菜鸟,不吝惜分数!~
{
string path = "";
if(folderBrowserDialog1.ShowDialog()==DialogResult.OK)
{
folderBrowserDialog1.ShowNewFolderButton = true;
path=folderBrowserDialog1.SelectedPath;
FileStream aFile = new FileStream("Log.txt", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(aFile); bool truth = true;
// Write data to file.
sw.WriteLine("Hello to you.");
sw.WriteLine("It is now {0} and things are looking good.",
DateTime.Now.ToLongDateString());
sw.Write("More than that,");
sw.Write(" it's {0} that C# is fun.", truth);
sw.Close();
}
}先创建一个文件夹。
然后创建一个txt文件,Log.txt,想把该文件放在创建的那个文件夹中,可是系统默认放在文件夹debug中,怎么办啊!
高手们,请赐教,我是菜鸟,不吝惜分数!~
解决方案 »
- strcitys.Split(',').Contains(scity) scity这样的一句话 该怎么写 这个语句,请高人指点下
- WinForm 使用webbrowser浏览网站,超连接是_blank的时候如何改成跳转
- 求助:datagridview数据输入格式问题?
- 有多少人关心Excel操作与打印?这里提供VB.Net、C#的使用方法及Web下导出Excel的解决方法...
- 求救坐标转换的问题
- 问Init函数,是不是每次 会送服务器都会执行?
- 急求医保刷卡的三个DLL文件,SSC打头的,谢谢各位!!!
- 请教一个格式转换的问题
- 给初学者推荐<C#程序设计>
- 求 C#对FAX的编程教程
- C# 多线程 操作Datable
- 如何将Object转换成List 或 通过Type实例化List<T>
=>
FileStream aFile = new FileStream(Path.Combine(path, "Log.txt"), FileMode.OpenOrCreate);