Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Nodejs如何创建包含同名文件的目录_Node.js - Fatal编程技术网

Node.js Nodejs如何创建包含同名文件的目录

Node.js Nodejs如何创建包含同名文件的目录,node.js,Node.js,我正在使用node package创建文件夹和文件,但文件不在正确的路径中。它们最终与文件夹位于同一级别,我需要将每个文件包含在新创建的文件夹中 fs.mkdirs(filenames[i], function (err) { if (!err){ fs.writeFile( './'+filenames[i]+'.html', 'hello world' , function( error ){ console.log(error); }); } })

我正在使用node package创建文件夹和文件,但文件不在正确的路径中。它们最终与文件夹位于同一级别,我需要将每个文件包含在新创建的文件夹中

fs.mkdirs(filenames[i], function (err) {

  if (!err){
    fs.writeFile( './'+filenames[i]+'.html', 'hello world' , function( error ){
      console.log(error);

    });
  }

});

我想这可能是你想要的:

fs.mkdirs(filenames[i], function (err) {

  if (!err){
    fs.writeFile(filenames[i]+'/'+filenames[i]+'.html', 'hello world' , function( error ){
      console.log(error);

    });
  }

});

我想这可能是你想要的:

fs.mkdirs(filenames[i], function (err) {

  if (!err){
    fs.writeFile(filenames[i]+'/'+filenames[i]+'.html', 'hello world' , function( error ){
      console.log(error);

    });
  }

});

文件的实际名称是什么?文件的实际名称是什么?