Electron解压缩文件

解压sdk选择

javascript 复制代码
   npm install adm-zip

解压示例

javascript 复制代码
    const AdmZip = require('adm-zip');

    // Specify the path to your zip file and the destination directory
    const zipFilePath = 'path/to/your/file.zip';
    const destinationPath = 'path/to/extract/to';

    try {
        const zip = new AdmZip(zipFilePath);
        zip.extractAllTo(destinationPath, /* overwrite */ true); // Set true to overwrite existing files
        console.log('Extraction complete!');
    } catch (error) {
        console.error('Error during extraction:', error);
    }