-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
SaveFile.go
37 lines (35 loc) · 815 Bytes
/
SaveFile.go
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
37
package main
import (
"github.com/harry1453/go-common-file-dialog/cfd"
"github.com/harry1453/go-common-file-dialog/cfdutil"
"log"
)
func main() {
result, err := cfdutil.ShowSaveFileDialog(cfd.DialogConfig{
Title: "Save A File",
Role: "SaveFileExample",
FileFilters: []cfd.FileFilter{
{
DisplayName: "Text Files (*.txt)",
Pattern: "*.txt",
},
{
DisplayName: "Image Files (*.jpg, *.png)",
Pattern: "*.jpg;*.png",
},
{
DisplayName: "All Files (*.*)",
Pattern: "*.*",
},
},
SelectedFileFilterIndex: 1,
FileName: "image.jpg",
DefaultExtension: "jpg",
})
if err == cfd.ErrorCancelled {
log.Fatal("Dialog was cancelled by the user.")
} else if err != nil {
log.Fatal(err)
}
log.Printf("Chosen file: %s\n", result)
}