平台介绍 >> js/jsfun/fnIO.js IO操作
js/jsfun/fnIO.js IO操作
//创建文件夹
fnIO_createFolder(fnJsa_jsCodePath()+"/demoresource/io")
let file=fnJsa_jsCodePath()+"/demoresource/io/io1.txt"
let fileNew=fnJsa_jsCodePath()+"/demoresource/io/io12.txt"
//保存文件
fnIO_saveFile(file, "当前时间:"+fnTime_now("Ymd H:i:s"),true)
//复制文件
fnIO_copy(file,fileNew)
//复制文件夹
fnIO_copyFolder(fnJsa_jsCodePath()+"/demoresource/io",fnJsa_jsCodePath()+"/demoresource/io_copy")
//IO存在,可具体到文件、文件夹
console.log("IO存在", fnIO_exist(file))
console.log("文件存在", fnIO_exist(file,1))
console.log("文件夹存在", fnIO_exist(file,2))
console.log("文件夹存在", fnIO_exist(fnJsa_jsCodePath()+"/demoresource/io",2))
console.log("文件字节:", fnIO_getFileByte(file))
console.log("文件文本:", fnIO_getFileContent(file))
console.log("文件夹列表1:", fnIO_getFiles(fnJsa_jsCodePath()+"/demoresource/io",".txt"))
console.log("文件夹列表2:", fnIO_getFiles(fnJsa_jsCodePath()+"/demoresource/io",".txt",false,true))
console.log("文件夹列表3:", fnIO_getFiles(fnJsa_jsCodePath()+"/demoresource/io",".txt",true))
console.log("文件夹列表4:", fnIO_getFiles(fnJsa_jsCodePath()+"/demoresource/io",".txt",true,true))
console.log("文件夹列表5:", fnIO_getFiles(fnJsa_jsCodePath()+"/demoresource/io","",true,true))
//删除文件或目录
fnIO_remove(fileNew)
fnIO_copyFolder(fnJsa_jsCodePath()+"/demoresource/io_copy",fnJsa_jsCodePath()+"/demoresource/io_copy2")
fnIO_remove(fnJsa_jsCodePath()+"/demoresource/io_copy2",true)
//复制文件
fnIO_copy(file,fileNew)
//重命名
fnIO_rename(fileNew,fnJsa_jsCodePath()+"/demoresource/io/io13.txt")
fnIO_saveFile(file,"当前时间:"+ fnTime_now("Y-m-d H:i:s"))
let bytes= fnIO_getFileByte(file)
fnIO_saveFileByte(fnJsa_jsCodePath()+"/demoresource/io/io14.txt",bytes,true)