首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

『C#』 中创建文件的存储路径有关问题!高手快来

2012-10-20 
『C#』 中创建文件的存储路径问题!!!急急急!!!高手快来!private void button1_Click(object sender, EventAr

『C#』 中创建文件的存储路径问题!!!急急急!!!高手快来!
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中,怎么办啊!
高手们,请赐教,我是菜鸟,不吝惜分数!~

[解决办法]
= =,刚发完贴,就解决了,2啊!~

热点排行