SaveFileDialog savefiledialog = new SaveFileDialog();
//设置文件类型
savefiledialog.Filter = "文本文件(*.doc)|*.doc|文本文件(*.txt)|*.txt";
//设置默认文件类型显示顺序
savefiledialog.FilterIndex = 1;
//保存对话框是否记忆上次打开的目录
savefiledialog.RestoreDirectory = true;
//设置默认的文件名
savefiledialog.FileName = "文件";
if (savefiledialog.ShowDialog()==DialogResult.OK)
{
//获取文件的路径 不带文件名
var folderpath = System.IO.Path.GetDirectoryName(savefiledialog.FileName);
}
//获取文件的完整路径 带文件名
var localFilePath= savefiledialog.FileName.ToString();
//获取文件名
var fileNameExt = localFilePath.Substring(localFilePath.LastIndexOf("\\") + 1);
//获取文件类型的index
var index = savefiledialog.FilterIndex;