仅从“保存文件”对话框中获取名称

时间:2011-12-01 10:53:29

标签: c# winforms savefiledialog

如何仅使用“保存文件对话框”获取文件名?

    MessageBox.Show("File was created with name: " + SOME CODE HERE + 
        Environment.NewLine + Environment.NewLine + 
        "You can find it at: " + Environment.NewLine + sfdNewFile.FileName);

2 个答案:

答案 0 :(得分:6)

System.IO.Path.GetFileName;

您可以使用参数sfdNewFile.FileName

调用它

答案 1 :(得分:5)

使用:

System.IO.Path GetFileName(sfdNewFile.FileName);

示例:

MessageBox.Show("File was created with name: " + SOME CODE HERE + 
        Environment.NewLine + Environment.NewLine + 
        "You can find it at: " + Environment.NewLine + System.IO.Path.GetFileName(sfdNewFile.FileName));