日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)小程序教程:微信小程序API 文件·文件管理器

FileSystemManager

基礎(chǔ)庫 1.9.9 開始支持,低版本需做 兼容處理。

公司主營業(yè)務(wù):網(wǎng)站設(shè)計、網(wǎng)站制作、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊有機(jī)會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)推出桂平免費做網(wǎng)站回饋大家。

文件管理器


方法:

FileSystemManager.access(Object object)

判斷文件/目錄是否存在

參數(shù)

Object object

屬性類型默認(rèn)值必填說明
pathstring要判斷是否存在的文件/目錄路徑 (本地路徑)
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail no such file or directory ${path}文件/目錄不存在

FileSystemManager.accessSync(string path)

FileSystemManager.access 的同步版本

參數(shù)

string path

要判斷是否存在的文件/目錄路徑 (本地路徑)

錯誤

錯誤碼錯誤信息說明
fail no such file or directory ${path}文件/目錄不存在

FileSystemManager.appendFile(Object object)

基礎(chǔ)庫 2.1.0 開始支持,低版本需做 兼容處理。

在文件結(jié)尾追加內(nèi)容

參數(shù)

Object object

屬性類型默認(rèn)值必填說明
filePathstring要追加內(nèi)容的文件路徑 (本地路徑)
datastring/ArrayBuffer要追加的文本或二進(jìn)制數(shù)據(jù)
encodingstringutf8指定寫入文件的字符編碼
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.encoding 的合法值

說明最低版本
ascii
base64
binary
hex
ucs2以小端序讀取
ucs-2以小端序讀取
utf16le以小端序讀取
utf-16le以小端序讀取
utf-8
utf8
latin1

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail no such file or directory, open ${filePath}指定的 filePath 文件不存在
fail illegal operation on a directory, open "${filePath}"指定的 filePath 是一個已經(jīng)存在的目錄
fail permission denied, open ${dirPath}指定的 filePath 路徑?jīng)]有寫權(quán)限
fail sdcard not mounted指定的 filePath 是一個已經(jīng)存在的目錄

FileSystemManager.appendFileSync(string filePath, string|ArrayBuffer data, string encoding)

基礎(chǔ)庫 2.1.0 開始支持,低版本需做 兼容處理。

FileSystemManager.appendFile 的同步版本

參數(shù)

string filePath

要追加內(nèi)容的文件路徑 (本地路徑)

string|ArrayBuffer data

要追加的文本或二進(jìn)制數(shù)據(jù)

string encoding

指定寫入文件的字符編碼

encoding 的合法值

說明最低版本
ascii
base64
binary
hex
ucs2以小端序讀取
ucs-2以小端序讀取
utf16le以小端序讀取
utf-16le以小端序讀取
utf-8
utf8
latin1

錯誤

錯誤碼錯誤信息說明
fail no such file or directory, open ${filePath}指定的 filePath 文件不存在
fail illegal operation on a directory, open "${filePath}"指定的 filePath 是一個已經(jīng)存在的目錄
fail permission denied, open ${dirPath}指定的 filePath 路徑?jīng)]有寫權(quán)限
fail sdcard not mounted指定的 filePath 是一個已經(jīng)存在的目錄

FileSystemManager.copyFile(Object object)

復(fù)制文件

參數(shù)

Object object

屬性類型默認(rèn)值必填說明
srcPathstring源文件路徑,支持本地路徑
destPathstring目標(biāo)文件路徑,支持本地路徑
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail permission denied, copyFile ${srcPath} -> ${destPath}指定目標(biāo)文件路徑?jīng)]有寫權(quán)限
fail no such file or directory, copyFile ${srcPath} -> ${destPath}源文件不存在,或目標(biāo)文件路徑的上層目錄不存在
fail the maximum size of the file storage limit is exceeded存儲空間不足

FileSystemManager.copyFileSync(string srcPath, string destPath)

FileSystemManager.copyFile 的同步版本

參數(shù)

string srcPath

源文件路徑,支持本地路徑

string destPath

目標(biāo)文件路徑,支持本地路徑

錯誤

錯誤碼錯誤信息說明
fail permission denied, copyFile ${srcPath} -> ${destPath}指定目標(biāo)文件路徑?jīng)]有寫權(quán)限
fail no such file or directory, copyFile ${srcPath} -> ${destPath}源文件不存在,或目標(biāo)文件路徑的上層目錄不存在
fail the maximum size of the file storage limit is exceeded存儲空間不足

FileSystemManager.getFileInfo(Object object)

獲取該小程序下的 本地臨時文件 或 本地緩存文件 信息

參數(shù)

Object object

屬性類型默認(rèn)值必填說明
filePathstring要讀取的文件路徑 (本地路徑)
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.success 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
sizenumber文件大小,以字節(jié)為單位

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail file not exist指定的 filePath 找不到文件

FileSystemManager.getSavedFileList(Object object)

獲取該小程序下已保存的本地緩存文件列表

參數(shù)

Object object

屬性類型默認(rèn)值必填說明
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.success 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
fileListArray.文件數(shù)組

res.fileList 的結(jié)構(gòu)

屬性類型說明
filePathstring文件路徑 (本地路徑)
sizenumber本地文件大小,以字節(jié)為單位
createTimenumber文件保存時的時間戳,從1970/01/01 08:00:00 到當(dāng)前時間的秒數(shù)

FileSystemManager.mkdir(Object object)

創(chuàng)建目錄

參數(shù)

Object object

屬性類型默認(rèn)值必填說明最低版本
dirPathstring創(chuàng)建的目錄路徑 (本地路徑)
recursivebooleanfalse是否在遞歸創(chuàng)建該目錄的上級目錄后再創(chuàng)建該目錄。如果對應(yīng)的上級目錄已經(jīng)存在,則不創(chuàng)建該上級目錄。如 dirPath 為 a/b/c/d 且 recursive 為 true,將創(chuàng)建 a 目錄,再在 a 目錄下創(chuàng)建 b 目錄,以此類推直至創(chuàng)建 a/b/c 目錄下的 d 目錄。2.3.0
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail no such file or directory ${dirPath}上級目錄不存在
fail permission denied, open ${dirPath}指定的 filePath 路徑?jīng)]有寫權(quán)限
fail file already exists ${dirPath}有同名文件或目錄

FileSystemManager.mkdirSync(string dirPath, boolean recursive)

FileSystemManager.mkdir 的同步版本

參數(shù)

string dirPath

創(chuàng)建的目錄路徑 (本地路徑)

boolean recursive

基礎(chǔ)庫 2.3.0 開始支持,低版本需做 兼容處理。

是否在遞歸創(chuàng)建該目錄的上級目錄后再創(chuàng)建該目錄。如果對應(yīng)的上級目錄已經(jīng)存在,則不創(chuàng)建該上級目錄。如 dirPath 為 a/b/c/d 且 recursive 為 true,將創(chuàng)建 a 目錄,再在 a 目錄下創(chuàng)建 b 目錄,以此類推直至創(chuàng)建 a/b/c 目錄下的 d 目錄。

錯誤

錯誤碼錯誤信息說明
fail no such file or directory ${dirPath}上級目錄不存在
fail permission denied, open ${dirPath}指定的 filePath 路徑?jīng)]有寫權(quán)限
fail file already exists ${dirPath}有同名文件或目錄

FileSystemManager.readdir(Object object)

讀取目錄內(nèi)文件列表

參數(shù)

Object object

屬性類型默認(rèn)值必填說明
dirPathstring要讀取的目錄路徑 (本地路徑)
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.success 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
filesArray.指定目錄下的文件名數(shù)組。

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail no such file or directory ${dirPath}目錄不存在
fail not a directory ${dirPath}dirPath 不是目錄
fail permission denied, open ${dirPath}指定的 filePath 路徑?jīng)]有讀權(quán)限

Array. FileSystemManager.readdirSync(string dirPath)

FileSystemManager.readdir 的同步版本

參數(shù)

string dirPath

要讀取的目錄路徑 (本地路徑)

返回值

Array. files

指定目錄下的文件名數(shù)組。

錯誤

錯誤碼錯誤信息說明
fail no such file or directory ${dirPath}目錄不存在
fail not a directory ${dirPath}dirPath 不是目錄
fail permission denied, open ${dirPath}指定的 filePath 路徑?jīng)]有讀權(quán)限

FileSystemManager.readFile(Object object)

讀取本地文件內(nèi)容

參數(shù)

Object object

屬性類型默認(rèn)值必填說明最低版本
filePathstring要讀取的文件的路徑 (本地路徑)
encodingstring指定讀取文件的字符編碼,如果不傳 encoding,則以 ArrayBuffer 格式讀取文件的二進(jìn)制內(nèi)容
positionstring從文件指定位置開始讀,如果不指定,則從文件頭開始讀。讀取的范圍應(yīng)該是左閉右開區(qū)間 [position, position+length)。有效范圍:[0, fileLength - 1]。單位:byte2.10.0
lengthstring指定文件的長度,如果不指定,則讀到文件末尾。有效范圍:[1, fileLength]。單位:byte2.10.0
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.encoding 的合法值

說明最低版本
ascii
base64
binary
hex
ucs2以小端序讀取
ucs-2以小端序讀取
utf16le以小端序讀取
utf-16le以小端序讀取
utf-8
utf8
latin1

object.success 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
datastring/ArrayBuffer文件內(nèi)容

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail no such file or directory, open ${filePath}指定的 filePath 所在目錄不存在
fail permission denied, open ${dirPath}指定的 filePath 路徑?jīng)]有讀權(quán)限

string|ArrayBuffer FileSystemManager.readFileSync(string filePath, string encoding, string position, string length)

FileSystemManager.readFile 的同步版本

參數(shù)

string filePath

要讀取的文件的路徑 (本地路徑)

string encoding

指定讀取文件的字符編碼,如果不傳 encoding,則以 ArrayBuffer 格式讀取文件的二進(jìn)制內(nèi)容

encoding 的合法值

說明最低版本
ascii
base64
binary
hex
ucs2以小端序讀取
ucs-2以小端序讀取
utf16le以小端序讀取
utf-16le以小端序讀取
utf-8
utf8
latin1

string position

基礎(chǔ)庫 2.10.0 開始支持,低版本需做 兼容處理。

從文件指定位置開始讀,如果不指定,則從文件頭開始讀。讀取的范圍應(yīng)該是左閉右開區(qū)間 [position, position+length)。有效范圍:[0, fileLength - 1]。單位:byte

string length

基礎(chǔ)庫 2.10.0 開始支持,低版本需做 兼容處理。

指定文件的長度,如果不指定,則讀到文件末尾。有效范圍:[1, fileLength]。單位:byte

返回值

string|ArrayBuffer data

文件內(nèi)容

錯誤

錯誤碼錯誤信息說明
fail no such file or directory, open ${filePath}指定的 filePath 所在目錄不存在
fail permission denied, open ${dirPath}指定的 filePath 路徑?jīng)]有讀權(quán)限

FileSystemManager.removeSavedFile(Object object)

刪除該小程序下已保存的本地緩存文件

參數(shù)

Object object

屬性類型默認(rèn)值必填說明
filePathstring需要刪除的文件路徑 (本地路徑)
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail file not exist指定的 tempFilePath 找不到文件

FileSystemManager.rename(Object object)

重命名文件??梢园盐募?oldPath 移動到 newPath

參數(shù)

Object object

屬性類型默認(rèn)值必填說明
oldPathstring源文件路徑,支持本地路徑
newPathstring新文件路徑,支持本地路徑
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail permission denied, rename ${oldPath} -> ${newPath}指定源文件或目標(biāo)文件沒有寫權(quán)限
fail no such file or directory, rename ${oldPath} -> ${newPath}源文件不存在,或目標(biāo)文件路徑的上層目錄不存在

FileSystemManager.renameSync(string oldPath, string newPath)

FileSystemManager.rename 的同步版本

參數(shù)

string oldPath

源文件路徑,支持本地路徑

string newPath

新文件路徑,支持本地路徑

錯誤

錯誤碼錯誤信息說明
fail permission denied, rename ${oldPath} -> ${newPath}指定源文件或目標(biāo)文件沒有寫權(quán)限
fail no such file or directory, rename ${oldPath} -> ${newPath}源文件不存在,或目標(biāo)文件路徑的上層目錄不存在

FileSystemManager.rmdir(Object object)

刪除目錄

參數(shù)

Object object

屬性類型默認(rèn)值必填說明最低版本
dirPathstring要刪除的目錄路徑 (本地路徑)
recursivebooleanfalse是否遞歸刪除目錄。如果為 true,則刪除該目錄和該目錄下的所有子目錄以及文件。2.3.0
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail no such file or directory ${dirPath}目錄不存在
fail directory not empty目錄不為空
fail permission denied, open ${dirPath}指定的 dirPath 路徑?jīng)]有寫權(quán)限

FileSystemManager.rmdirSync(string dirPath, boolean recursive)

FileSystemManager.rmdir 的同步版本

參數(shù)

string dirPath

要刪除的目錄路徑 (本地路徑)

boolean recursive

基礎(chǔ)庫 2.3.0 開始支持,低版本需做 兼容處理。

是否遞歸刪除目錄。如果為 true,則刪除該目錄和該目錄下的所有子目錄以及文件。

錯誤

錯誤碼錯誤信息說明
fail no such file or directory ${dirPath}目錄不存在
fail directory not empty目錄不為空
fail permission denied, open ${dirPath}指定的 dirPath 路徑?jīng)]有寫權(quán)限

FileSystemManager.saveFile(Object object)

保存臨時文件到本地。此接口會移動臨時文件,因此調(diào)用成功后,tempFilePath 將不可用。

參數(shù)

Object object

屬性類型默認(rèn)值必填說明
tempFilePathstring臨時存儲文件路徑 (本地路徑)
filePathstring要存儲的文件路徑 (本地路徑)
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.success 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
savedFilePathstring存儲后的文件路徑 (本地路徑)

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail tempFilePath file not exist指定的 tempFilePath 找不到文件
fail permission denied, open "${filePath}"指定的 filePath 路徑?jīng)]有寫權(quán)限
fail no such file or directory "${dirPath}"上級目錄不存在
fail the maximum size of the file storage limit is exceeded存儲空間不足

string FileSystemManager.saveFileSync(string tempFilePath, string filePath)

FileSystemManager.saveFile 的同步版本

參數(shù)

string tempFilePath

臨時存儲文件路徑 (本地路徑)

string filePath

要存儲的文件路徑 (本地路徑)

返回值

string savedFilePath

存儲后的文件路徑 (本地路徑)

錯誤

錯誤碼錯誤信息說明
fail tempFilePath file not exist指定的 tempFilePath 找不到文件
fail permission denied, open "${filePath}"指定的 filePath 路徑?jīng)]有寫權(quán)限
fail no such file or directory "${dirPath}"上級目錄不存在
fail the maximum size of the file storage limit is exceeded存儲空間不足

FileSystemManager.stat(Object object)

獲取文件 Stats 對象

參數(shù)

Object object

屬性類型默認(rèn)值必填說明最低版本
pathstring文件/目錄路徑 (本地路徑)
recursivebooleanfalse是否遞歸獲取目錄下的每個文件的 Stats 信息2.3.0
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.success 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
statsStats/Object當(dāng) recursive 為 false 時,res.stats 是一個 Stats 對象。當(dāng) recursive 為 true 且 path 是一個目錄的路徑時,res.stats 是一個 Object,key 以 path 為根路徑的相對路徑,value 是該路徑對應(yīng)的 Stats 對象。

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail permission denied, open ${path}指定的 path 路徑?jīng)]有讀權(quán)限
fail no such file or directory ${path}文件不存在

示例代碼

recursive 為 false 時


let fs = wx.getFileSystemManager()
fs.stat({
  path: `${wx.env.USER_DATA_PATH}/testDir`,
  success: res => {
    console.log(res.stats.isDirectory())
  }
})

recursive 為 true 時


fs.stat({
  path: `${wx.env.USER_DATA_PATH}/testDir`,
  recursive: true,
  success: res => {
    Object.keys(res.stats).forEach(path => {
      let stats = res.stats[path]
      console.log(path, stats.isDirectory())
    })
  }
})

Stats|Object FileSystemManager.statSync(string path, boolean recursive)

FileSystemManager.stat 的同步版本

參數(shù)

string path

文件/目錄路徑 (本地路徑)

boolean recursive

基礎(chǔ)庫 2.3.0 開始支持,低版本需做 兼容處理。

是否遞歸獲取目錄下的每個文件的 Stats 信息

返回值

Stats|Object stats

當(dāng) recursive 為 false 時,res.stats 是一個 Stats 對象。當(dāng) recursive 為 true 且 path 是一個目錄的路徑時,res.stats 是一個 Object,key 以 path 為根路徑的相對路徑,value 是該路徑對應(yīng)的 Stats 對象。

錯誤

錯誤碼錯誤信息說明
fail permission denied, open ${path}指定的 path 路徑?jīng)]有讀權(quán)限
fail no such file or directory ${path}文件不存在

示例代碼

recursive 為 false 時


let fs = wx.getFileSystemManager()
fs.stat({
  path: `${wx.env.USER_DATA_PATH}/testDir`,
  success: res => {
    console.log(res.stats.isDirectory())
  }
})

recursive 為 true 時


fs.stat({
  path: `${wx.env.USER_DATA_PATH}/testDir`,
  recursive: true,
  success: res => {
    Object.keys(res.stats).forEach(path => {
      let stats = res.stats[path]
      console.log(path, stats.isDirectory())
    })
  }
})

FileSystemManager.unlink(Object object)

刪除文件

參數(shù)

Object object

屬性類型默認(rèn)值必填說明
filePathstring要刪除的文件路徑 (本地路徑)
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail permission denied, open ${path}指定的 path 路徑?jīng)]有讀權(quán)限
fail no such file or directory ${path}文件不存在
fail operation not permitted, unlink ${filePath}傳入的 filePath 是一個目錄

FileSystemManager.unlinkSync(string filePath)

FileSystemManager.unlink 的同步版本

參數(shù)

string filePath

要刪除的文件路徑 (本地路徑)

錯誤

錯誤碼錯誤信息說明
fail permission denied, open ${path}指定的 path 路徑?jīng)]有讀權(quán)限
fail no such file or directory ${path}文件不存在
fail operation not permitted, unlink ${filePath}傳入的 filePath 是一個目錄

FileSystemManager.unzip(Object object)

解壓文件

參數(shù)

Object object

屬性類型默認(rèn)值必填說明
zipFilePathstring源文件路徑,支持本地路徑, 只可以是 zip 壓縮文件
targetPathstring目標(biāo)目錄路徑, 支持本地路徑
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail permission denied, unzip ${zipFilePath} -> ${destPath}指定目標(biāo)文件路徑?jīng)]有寫權(quán)限
fail no such file or directory, unzip ${zipFilePath} -> "${destPath}源文件不存在,或目標(biāo)文件路徑的上層目錄不存在

FileSystemManager.writeFile(Object object)

寫文件

參數(shù)

Object object

屬性類型默認(rèn)值必填說明
filePathstring要寫入的文件路徑 (本地路徑)
datastring/ArrayBuffer要寫入的文本或二進(jìn)制數(shù)據(jù)
encodingstringutf8指定寫入文件的字符編碼
successfunction接口調(diào)用成功的回調(diào)函數(shù)
failfunction接口調(diào)用失敗的回調(diào)函數(shù)
completefunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

object.encoding 的合法值

說明最低版本
ascii
base64
binary
hex
ucs2以小端序讀取
ucs-2以小端序讀取
utf16le以小端序讀取
utf-16le以小端序讀取
utf-8
utf8
latin1

object.fail 回調(diào)函數(shù)

參數(shù)
Object res
屬性類型說明
errMsgstring錯誤信息

res.errMsg 的合法值

說明最低版本
fail no such file or directory, open ${filePath}指定的 filePath 所在目錄不存在
fail permission denied, open ${dirPath}指定的 filePath 路徑?jīng)]有寫權(quán)限
fail the maximum size of the file storage limit is exceeded存儲空間不足

FileSystemManager.writeFileSync(string filePath, string|ArrayBuffer data, string encoding)

FileSystemManager.writeFile 的同步版本

參數(shù)

string filePath

要寫入的文件路徑 (本地路徑)

string|ArrayBuffer data

要寫入的文本或二進(jìn)制數(shù)據(jù)

string encoding

指定寫入文件的字符編碼

encoding 的合法值

說明最低版本
ascii
base64
binary
hex
ucs2以小端序讀取
ucs-2以小端序讀取
utf16le以小端序讀取
utf-16le以小端序讀取
utf-8
utf8
latin1

錯誤

錯誤碼錯誤信息說明
fail no such file or directory, open ${filePath}指定的 filePath 所在目錄不存在
fail permission denied, open ${dirPath}指定的 filePath 路徑?jīng)]有寫權(quán)限
fail the maximum size of the file storage limit is exceeded存儲空間不足

網(wǎng)站欄目:創(chuàng)新互聯(lián)小程序教程:微信小程序API 文件·文件管理器
本文路徑:http://www.5511xx.com/article/dpjogph.html