archive icon indicating copy to clipboard operation
archive copied to clipboard

Extracted Files are hidden when connected to PC.

Open krngd2 opened this issue 6 years ago • 1 comments
trafficstars

I have downloaded a zip from a link and extracted the files to the same folder in a sub directory, I can clearly see these files from local file explorer but when i connect it to my pc, the folders are not listed. The code I used

extractFiles() async{
    final dir = await Storage().localPath;
    final _directory = Directory(dir+"/bizzapp/zip");
    List<FileSystemEntity> _files;
    _files  = _directory.listSync(recursive: true, followLinks: false);  
    // Read the Zip file from disk.
    List<int> bytes = new File(_files[0].path).readAsBytesSync();

    // Decode the Zip file
    Archive archive = new ZipDecoder().decodeBytes(bytes);

    // Extract the contents of the Zip archive to disk.
    for (ArchiveFile file in archive) {
      String filename = file.name;
      if (file.isFile) {
        List<int> data = file.content;
        new File(dir+'/bizzapp/' + filename)
          ..createSync(recursive: true)
          ..writeAsBytesSync(data);
      } else {
        new Directory(dir+'/bizzapp/' + filename)
          ..create(recursive: true);
      }
    }
  }

krngd2 avatar Mar 18 '19 10:03 krngd2

The file writing looks fine to me, I don't know what "connect it to my pc" means. The file saving is pure Dart functionality, so the Archive library doesn't have anything to do with that, other than providing the file content.

brendan-duncan avatar Mar 18 '19 18:03 brendan-duncan