摘要:
package main
import (
"fmt"
"io/ioutil"
)
func main() {
dirname := "D:\\EmptyDir"
dir, _ := ioutil.ReadDir(dirname)
if len(dir) == 0 {
fmt.Println(dirname + " is empty dir!")
} else {
fmt.Println(dirname + " is not empty dir!") 阅读全文
摘要:
package main
import (
"fmt"
"os"
)
func main() {
fileinfo, err := os.Stat(`C:\Users\Administrator\Desktop\UninstallTool.zip`)
if err != nil {
panic(err)
}
fmt.Println(fileinfo.Name()) //获取文件名
fmt.Println(fileinfo.IsDir()) //判断是否是目录,返回bool类型
fmt.Println(fileinfo.ModTime()) //获取文件修改时间
fmt.Println(fileinfo.Mode())
fmt.Println(fileinfo.Size()) //获取文件大小
fmt.Println 阅读全文