Instructions for the fs.renameSync method in node.js

  • 2020-05-05 10:54:08
  • OfStack

method description:

Synchronous version of rename().

syntax:


fs.renameSync(oldPath, newPath)

Since this method belongs to the fs module, it is necessary to introduce the fs module (var fs= require(" fs "))

before using it

receive parameters:

oldPath                          

newPath                         new path

example:


var fs = require('fs');
fs.renameSync('125.txt','126.txt');

source code:


fs.renameSync = function(oldPath, newPath) {
  nullCheck(oldPath);
  nullCheck(newPath);
  return binding.rename(pathModule._makeLong(oldPath),
                        pathModule._makeLong(newPath));
};


Related articles: