uniapp文件复制,重命名以及删除

查找某目录下的文件

plus.io.resolveLocalFileSystemURL(
        "_www/static/本地.png",
            function(entry){ //获取文件对象  
                console.log("entry:"+entry.fullPath);  
             }  
        )

复制文件

没有文件夹时会直接创建

var nname='zhuanhuan/iii'
                        entry.copyTo(entry22,nname, function(newimage){  
                                console.log("808");
                            console.log(newimage.fullPath);    
                            } ,
                             function(newimage){
                                 console.log("808err");
                             console.log(newimage);    
  } );

删除文件夹以及根目录

plus.io.resolveLocalFileSystemURL(
                    "_downloads",
                        function(entry22){ //获取文件对象  
                        console.log("entry223:"+entry22.fullPath);
                    // 删除操作

//https://www.html5plus.org/doc/zh_cn/io.html#plus.io.DirectoryEntry.removeRecursively
                    entry22.removeRecursively( function ( entry ) {
                        plus.console.log( "Remove Recursively Succeeded" );
                    }, function ( e ) {
                        //alert( e.message );
                    } );
                     // 删除单个文件
                    entry22.remove( function ( entry ) {
                        plus.console.log( "Remove Recursively Succeeded" );
                    }, function ( e ) {
                        //alert( e.message );
                    } );
                        }  
 )

/******/

复制

plus.io.resolveLocalFileSystemURL(
        "_www/static/本地",
            function(entry){ //获取文件对象  
                console.log("entry:"+entry.fullPath);  
                plus.io.resolveLocalFileSystemURL(
                    "_downloads",
                        function(entry22){ //获取文件对象  
                        console.log("entry223:"+entry22.fullPath);
                        var nname='zhuanhuan/iii'
                        entry.copyTo(entry22,nname, function(newimage){  
                                console.log("808");
                            console.log(newimage.fullPath);    
                            } ,
                             function(newimage){
                                 console.log("808err");
                             console.log(newimage);    
                             } );    
                        
                    
                        }  
                    )
                
            
        
            }  
        )

删除

plus.io.resolveLocalFileSystemURL(
                            "_doc",
                                function(entry22){ //获取文件对象  
                                console.log("entry223:"+entry22.fullPath);
                            // remove the directory and all it's contents
                            entry22.removeRecursively( function ( entry ) {
                                plus.console.log( "Remove Recursively Succeeded" );
                            }, function ( e ) {
                                //alert( e.message );
                            } );
                            
                                }  
                            )

posted on 2023-02-06 14:34  Just丶随心  阅读(1271)  评论(0编辑  收藏  举报

导航