c# - 如何在 SaveFileDialog 中设置初始文件名?
问题描述
我为保存文件对话框创建了一个脚本来保存文件。它的初始位置设置为桌面。现在我的问题是,如何在对话框中为文件设置初始“名称”?
这是我的代码:
private SaveFileDialog save = new SaveFileDialog();
private void Information(string Basic, string nameoffile, string program)
{
if (doingsomething) return;
System.Windows.Forms.MessageBox.Show($"Please select where you would like to store the file)"
save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
if (save.ShowDialog() == DialogResult.OK)
如果对此有答案,请指出我可以找到它的地方。因为我不知道确切的关键字。
解决方案
您可以分配默认名称,例如
save.FileName="File1";
推荐阅读
- bash - Bash,移动和重命名文件到基本父目录名称
- vue.js - Vue 3 - 如何使用 vuex 模块?
- android - React-Native:react-native-webview 如何在后台工作?
- sql-server - 全部在存储过程中的事务中
- c# - 如何在 Asp .Net 5 的控制器外使用 ApplicationDbContext
- c# - 使用 dotnet publish .NET 5 和 win-x64 时出现错误“NU1101:无法找到包 xyz”
- c# - 使用 PropertyChanged 事件创建自定义 ConfigurationElement
- python - 使用嵌套循环最小化 Python 代码占用空间
- react-native - React-Testing-Library/Jest-Dom - 接收到的值必须是 HTMLElement 或 SVGElement
- intellij-idea - HSQLDB 选择在 intellij IDEA 中显示没有数据