I am trying to check whether write permission exists inside a particular directory in my PC using Node.js. But I think Node.js is checking with respect to the admin user but when I try to download a file/directory inside that directory in the electron app, it's returning Uncaught Exception. Error: EPERM: Operation not permitted, open <file-path>
.
fs.access(download_path, fs.constants.W_OK, (err) => {
console.log('Checking permission for downloading file...', download_path);
if(err) {
// Show an alert if no write access
const options = {
type: 'error',
message: `You do not have permission to download file(s) at ${download_path}`,
buttons: ['Ok']
};
dialog.showMessageBox(null, options, (response) => {
console.log(response);
});
console.log(`File(s) cannot be downloaded at ${download_path}`);
} else {
console.log('Downloading file(s)');
startDownload();
}
});
});