建立與刪除檔案,使用檔案選擇視窗…
private void button1_Click(object sender, EventArgs e)
{
SaveFileDialog mySaveFileDialog = new SaveFileDialog(); //新增檔案儲存視窗
if (mySaveFileDialog.ShowDialog() == DialogResult.OK)
{
File.Create(mySaveFileDialog.FileName); //新建文件(另存新檔視窗)
}
}
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog myOpenFileDialog = new OpenFileDialog(); //開啟檔案視窗
if (myOpenFileDialog.ShowDialog() == DialogResult.OK)
{
File.Delete(myOpenFileDialog.FileName); //del file
}
}
沒有留言:
張貼留言