-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathOpenMultipleFiles.go
43 lines (41 loc) · 937 Bytes
/
OpenMultipleFiles.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
38
39
40
41
42
43
package main
import (
"github.com/harry1453/go-common-file-dialog/cfd"
"log"
)
func main() {
openMultiDialog, err := cfd.NewOpenMultipleFilesDialog(cfd.DialogConfig{
Title: "Open Multiple Files",
Role: "OpenFilesExample",
FileFilters: []cfd.FileFilter{
{
DisplayName: "Text Files (*.txt)",
Pattern: "*.txt",
},
{
DisplayName: "Image Files (*.jpg, *.png)",
Pattern: "*.jpg;*.png",
},
{
DisplayName: "All Files (*.*)",
Pattern: "*.*",
},
},
SelectedFileFilterIndex: 2,
FileName: "file.txt",
DefaultExtension: "txt",
})
if err != nil {
log.Fatal(err)
}
if err := openMultiDialog.Show(); err != nil {
log.Fatal(err)
}
results, err := openMultiDialog.GetResults()
if err == cfd.ErrorCancelled {
log.Fatal("Dialog was cancelled by the user.")
} else if err != nil {
log.Fatal(err)
}
log.Printf("Chosen file(s): %s\n", results)
}