title: EBUSY: resource busy or locked, rename
body: <p>I have this problem going on with my app, so i have a stage folder where we receive files at, there is a fs.watch on the directory which will monitor files and move the file to another directory once it sees it . Just to mimic the process, I have the app running and copy/paste a file to the stage directory. But i keep getting the error , not sure how to overcome this</p>
  
  <p>EBUSY: resource busy or locked, rename 'C:\Users\a\Desktop\Node js Data Loader\stage_load\data\UI.txt' -> 'C:\Users\a\Desktop\Node js Data Loader\stage_load\stage\UI.txt'</p>
  
  <p>Here a snippet from my code</p>
  
  <pre><code>fs.watch(DATA_PATH,(eventype,filename) =&gt;
      {
  
          if(filename.length &gt; 0)
          {
              const data_name = path.join(DATA_PATH, filename);
              const stg_name = path.join(STAGE_PATH, filename);
              fs.rename(data_name,stg_name ,(err) =&gt;{
                  if(err)
                  {
                      console.log('File failed to move to Stage');
                      throw err;
                  }
  
              })
              main();
          }
  
      })
  </code></pre>
  
  <p>Seems like the code needs to wait for the full file to be written, not sure</p>