-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSaveFileDialog.cs
More file actions
36 lines (31 loc) · 1.18 KB
/
SaveFileDialog.cs
File metadata and controls
36 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Windows.Forms;
namespace FolderBrowserDialogExample {
class Form1 : Form {
// The main entry point for the application.
[STAThread]
public static void Main() {
Application.EnableVisualStyles();
Application.Run(new Form1());
}
public Form1() {
button.Text = "Save...";
button.Location = new System.Drawing.Point(10, 10);
button.Click += delegate(object sender, EventArgs e) {
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
saveFileDialog.FileName = "MyFile.txt";
saveFileDialog.Filter = "Text Files (*.txt)|*.txt;*.md|All Files (*.*)|*.*";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
label.Text = string.Format("File = {0}", saveFileDialog.FileName);
};
label.Text = "Path = ";
label.Location = new System.Drawing.Point(10, 40);
label.Width = 340;
Text = "SaveFileDialog example";
Controls.AddRange(new Control[] { button, label});
}
private Button button = new Button();
private Label label = new Label();
}
}