『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啊!~