实现效果:
知识运用:
DateTime结构的Now属性
File类的Create方法
实现代码:
private void button1_Click(object sender, EventArgs e) { FolderBrowserDialog fb = new FolderBrowserDialog(); if (fb.ShowDialog() == DialogResult.OK) { string fileName = DateTime.Now.ToString("yyyyMMdd-hhmmss")+".txt"; File.Create(fb.SelectedPath+"\"+fileName); } }