我在文件对话框中返回文件名时遇到问题。 我只需要更改文件名而不是路径 我想要这样的东西......
string name_to_change="abc";
string filenameAtClient = this.saveFileDialog.FileName;
filenameAtClient=name_to_change;
答案 0 :(得分:0)
也许您必须检查MSDN,例如:
答案 1 :(得分:0)
string name_to_change = "abc";
string filenameAtClient = this.saveFileDialog.FileName;
filenameAtClient = filenameAtClient.Replace(Path.GetFileName(filenameAtClient), name_to_change);
没有文件扩展名的OR:
string name_to_change = "abc";
string filenameAtClient = this.saveFileDialog.FileName;
filenameAtClient = filenameAtClient.Replace(Path.GetFileNameWithoutExtension(filenameAtClient), name_to_change);