From 70d47a8fd6dc6e6bc5a38e107a39d35314e3c410 Mon Sep 17 00:00:00 2001 From: wanganxp Date: Sun, 10 Dec 2023 06:32:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84file=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../get-file-system-manager.uvue | 67 ++++++++++++++++--- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/pages/API/get-file-system-manager/get-file-system-manager.uvue b/pages/API/get-file-system-manager/get-file-system-manager.uvue index d4d78335..029c0336 100644 --- a/pages/API/get-file-system-manager/get-file-system-manager.uvue +++ b/pages/API/get-file-system-manager/get-file-system-manager.uvue @@ -1,17 +1,19 @@ @@ -337,6 +339,49 @@ } } as UnLinkOptions) }, + unlinkAllFileTest:function(e:any){ + let fileManager = uni.getFileSystemManager() + fileManager.readdir({ + dirPath:`${this.basePath}${this.rmDirFile}`, + success:function(res:ReadDirSuccessResult){ + console.log("success to readdir",res) + res.files.forEach(element => { + console.log(element) + fileManager.unlink({ + filePath:`${this.basePath}${this.rmDirFile}/${element}`, + success:function(res:FileManagerSuccessResult){ + console.log('success unlink',res) + }, + fail:function(res:UniError){ + console.log('fail unlink',res) + this.lastFailError = res + }, + complete:function(res:any){ + if(res instanceof UniError){ + this.lastCompleteError = res + } + console.log("complete unlink",res) + this.done = true + } + } as UnLinkOptions) + }); + }, + fail:function(res:any){ + console.log('fail to readdir',res) + this.lastFailError = res + }, + complete:function(res:any){ + console.log("complete readdir",res) + this.done = true + if(res instanceof ReadDirSuccessResult){ + this.fileListComplete = res.files + } + if(res instanceof UniError){ + this.lastCompleteError = res + } + } + } as ReadDirOptions) + }, } } -- GitLab