实现效果:
知识运用:
File类的Create方法 //在指定路径中创建文件
public static FileStream Create (string Path)
File类的Delete方法 //删除指定文件 不存在则引发异常
public static FileStream Delete (string Path)
实现代码:
private void button1_Click(object sender, EventArgs e) { SaveFileDialog P_SaveFileDialog = new SaveFileDialog(); if (P_SaveFileDialog.ShowDialog() == DialogResult.OK) { File.Create(P_SaveFileDialog.FileName); } } private void button2_Click(object sender, EventArgs e) { OpenFileDialog P_OpenFileDialog = new OpenFileDialog(); if (P_OpenFileDialog.ShowDialog() == DialogResult.OK) { File.Delete(P_OpenFileDialog.FileName); } }
原文:https://www.cnblogs.com/feiyucha/p/10216774.html