C#的OpenFileDialog和SaveFileDialog的常见用法

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;//保存的文件的全限定名

你可能感兴趣的:(C#,ASP.NET)