0

这不起作用(目录存在时不会发生任何事情):

let s_dir = Gio.file_new_for_path("./S1");
try {
        s_dir.make_directory(null);
} catch(e) {
        if(e == Gio.IOErrorEnum.EXISTS)
            print(e);
}
4

1 回答 1

3

使用GLib.Error.matches()方法:

let s_dir = Gio.file_new_for_path("./S1");
try {
        s_dir.make_directory(null);
} catch(e) {
        if (e.matches (Gio.IOErrorEnum, Gio.IOErrorEnum.EXISTS)
            print(e);
}
于 2018-01-12T10:02:43.863 回答