简体   繁体   中英

I wonder if with (fs) I can copy a folder from one location to another

Is there a method to copy a folder from one place to another?

I used the method:

fs.copyFileSync()

However, it copies only files.

Is there a way for me to copy a folder from one location to another?

you can use exec function to execute an os command

const { exec } = require('child_process');
exec('cp -r <sorceFolderPath> <destFolderPath>', (err, stdout, stderr) => {
  }

this may differ with OS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM