起初,做了个小程序,用来检测磁盘中所有的文件
package mainimport("fmt""io/ioutil""os")var dirpath ="D:\"func main(){CheckDir(dirpath)}func CheckDir(dirpath string){dirs, err := ioutil.ReadDir(dirpath)if err !=nil{panic("目录输入有误!")}for _, dir := range dirs {if dir.IsDir(){if dir.Name()=="System Volume Information"{fmt.Println("检测目录:", dirpath+"\"+dir.Name(),"sys", dir.Sys())return}fmt.Println("检测目录:", dirpath+"\"+dir.Name(),"sys", dir.Sys())CheckDir(dirpath +"\"+ dir.Name())}else{fmt.Println("文件:", dirpath+"\"+dir.Name(),"大小:", dir.Size())if dir.Size()==0{fmt.Println("删除文件:", dirpath+"\"+dir.Name(), dir.Size())}}}} 输出结果为:文件: D:\My DocumentsDownloadswcftestclient_exe.rar 大小: 110608
检测目录: D:\SoftDown sys &{16 {2081520578 30419524} {1134116594 30422735} {1134116594 30422735} 0 0}
文件: D:\SoftDownSublime Text Build 3012 Setup.exe 大小: 7051120
检测目录: D:\SoftDownVice.2015.720p.WEB-DL.DD5.1.H.264-PLAYNOW sys &{16 {753370423 30421925} {753410426 30421925} {753420426 30421925} 0 0}
文件: D:\SoftDownVice.2015.720p.WEB-DL.DD5.1.H.264-PLAYNOWVice.2015.720p.WEB-DL.DD5.1.H.264-PLAYNOW.mkv.tdl 大小: 3255167129
文件: D:\SoftDownVice.2015.720p.WEB-DL.DD5.1.H.264-PLAYNOWf7a8aa8e2082c4ebe28f2c26cf16e4b08a27d5c1.torrent 大小: 31751
文件: D:\SoftDownVice.2015.720p.WEB-DL.DD5.1.H.264-PLAYNOW.qud.cfg 大小: 556
文件: D:\SoftDown[iPlaySoft.com]VS2013_RTM_ULT_CHS.iso 大小: 3077509120
检测目录: D:\System Volume Information sys &{22 {1206047926 30310737} {1206983927 30310737} {1206983927 30310737} 0 0}
panic: 目录输入有误!
goroutine 1 [running]:
main.CheckDir(0xc0820585c0, 0x1d)
F:/goproj/GitTest.git/trunk/src/WebSite/main.go:22 +0xde
main.CheckDir(0x4f3890, 0x3)
F:/goproj/GitTest.git/trunk/src/WebSite/main.go:28 +0x46a
main.main()
F:/goproj/GitTest.git/trunk/src/WebSite/main.go:15 +0xfc
这里会报一个异常
D:\System Volume Information Microsoft的解答: