Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

181
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda