做文件保存,想默认文件名,有用户自己修改文件名,该怎么写?
string strStartPath = Application.StartupPath + "\\Map"; SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.InitialDirectory = strStartPath;
saveFileDialog.Filter = "文件(*.*)|*.*"; saveFileDialog.ShowDialog();
if (saveFileDialog.FileName == null)
{
string strNewName = "";
FileInfo fi = new FileInfo(saveFileDialog.FileName); strNewName = strStartPath + "\\" + fi.Name.Split(new char[] { '.' })[0]; if (fi.DirectoryName != strStartPath)
{
lab:
FileInfo fitmp = new FileInfo(strNewName + fi.Extension); if (fitmp.Exists)
{
strNewName += "1";
goto lab;
}
else
{
this.SelectFrom.ud_MapContrl.SaveToFile(strNewName + ".rwm", false);
}
}
else
{
SelectFrom.ud_MapContrl.SaveToFile(saveFileDialog.FileName, false);
} }
这个不对,不知道错在那里?谢谢
string strStartPath = Application.StartupPath + "\\Map"; SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.InitialDirectory = strStartPath;
saveFileDialog.Filter = "文件(*.*)|*.*"; saveFileDialog.ShowDialog();
if (saveFileDialog.FileName == null)
{
string strNewName = "";
FileInfo fi = new FileInfo(saveFileDialog.FileName); strNewName = strStartPath + "\\" + fi.Name.Split(new char[] { '.' })[0]; if (fi.DirectoryName != strStartPath)
{
lab:
FileInfo fitmp = new FileInfo(strNewName + fi.Extension); if (fitmp.Exists)
{
strNewName += "1";
goto lab;
}
else
{
this.SelectFrom.ud_MapContrl.SaveToFile(strNewName + ".rwm", false);
}
}
else
{
SelectFrom.ud_MapContrl.SaveToFile(saveFileDialog.FileName, false);
} }
这个不对,不知道错在那里?谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货