SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "txt files(*.txt)|*.txt|xls files(*.xls)|*.xls|All files(*.*)|*.*"; //过滤 sfd.DefaultExt = "txt"; //默认扩展名 DialogResult dr = sfd.ShowDialog(); if (dr == DialogResult.OK) { //your code }
SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "txt files(*.txt)|*.txt|xls files(*.xls)|*.xls|All files(*.*)|*.*"; //过滤 sfd.DefaultExt = "txt"; //默认扩展名 DialogResult dr = sfd.ShowDialog(); if (dr == DialogResult.OK) { //your code }