Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
how to move a file/image if not used by another app or process NodeJS

I'm trying to make a function that checks if file is opened or in use by another app or process using fs

and here is my attempt to do this

function isFileInUse() {
    try {
        const file = path.join(__dirname, '20200201072955946-2.jpg');
        //try to open file for checking if it is in use
        fs.access(file, fs.constants.W_OK, (err) => {
            if (err) {
                console.log('File is in use');
            } else {
                console.log('File is not in use');
            }
        });
        return false;
    }
    catch(error) {
        console.log(error);
        return true;
    }
}
isFileInUse()

this code somehow move the the image with no error even if it's run by another app like notepad++ or by image viewer

if someone can tell me what i'm doing wrong on this matter or help with this . that be great

thanks in advance

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!