首页 > 学院 > 开发设计 > 正文

C#的OpenFileDialog和SaveFileDialog的常见用法(转)

2019-11-14 16:18:40
字体:
来源:转载
供稿:网友

OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.InitialDirectory = strOpenFileFolder;//初始目录,不赋值也可以
openFileDialog1.Filter = “mxml文件(*.mxml)|*.mxml”;//文件类型
openFileDialog1.ShowDialog();//弹出选择框
String strOpenFileFolder = openFileDialog1.FileName.Substring(0,openFileDialog1.FileName.LastIndexOf(‘//’));//打开的文件的目录
String strOpenFileName = openFileDialog1.FileName;//打开的文件的全限定名

SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.InitialDirectory = strSaveFileName;//保存的默认目录,不赋值也可以
saveFileDialog1.Filter = “swf文件(*.swf)|*.swf”;//过滤显示的文件类型
saveFileDialog1.FileName = strOpenFileName.Substring(0,strOpenFileName.LastIndexOf(‘.’))+”.swf”;//保存的文件名
saveFileDialog1.ShowDialog();//弹出选择框
String strSaveFileFolder = saveFileDialog1.FileName.Substring(0,saveFileDialog1.FileName.LastIndexOf(‘//’));//保存的文件的目录
String strSaveFileName = saveFileDialog1.FileName;//保存的文件的全限定名


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表