Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda