UnhappyCreate Directory and File in Path

Posts 1–5 of 5 · Page 1 of 1
Create Directory and File in Path
Hello , my name is not .
i want to create directory and file in path .

for example :
Start > input field name ( name file ) > output name.php in c:\users\administrator\appdata\roaming\directory\ and write code in php file .

for example in php file :
<?php

echo "<a href="#">Output other field name in tag elements</a>";

?>

i think i should use #include < sys/stat.h> function .
Thank you .
I have no idea what your post is trying to say but I think you're wanting to create a directory and create a file?

Code:
#include <fstream>
#include <string>
#include <iostream>
#include <windows.h>

void main()
{
	std::string directory, fileName;
	std::ofstream fout;

	std::cout << "Directory: ";
	std::getline(std::cin, directory);

	//	If the last character in directory is not a \ then append a trailing \\ to the string to indicate to the CreateDirectory function that it is a directory
	if (directory.back() != '\\')
		directory += "\\";

	std::cout << "File name: ";
	std::getline(std::cin, fileName);

	if (CreateDirectory(directory.c_str(), NULL)) {
		fout.open(directory + fileName);
		fout.close();
	}
	else {
		std::cout << "Failed to create " << directory << std::endl;
	}
}
Quote Originally Posted by notnoyyyyy View Post
Hello , my name is not .
i want to create directory and file in path .

for example :
Start > input field name ( name file ) > output name.php in c:\users\administrator\appdata\roaming\directory\ and write code in php file .

for example in php file :
<?php

echo "<a href="#">Output other field name in tag elements</a>";

?>

i think i should use #include < sys/stat.h> function .
Thank you .
can you use fstream
see on : cplusplus.com/doc/tutorial/files/

i can't post link but i don't know why :/

to create directory in c++ you can use mkdir(only for windows) defined in direct.h or you can use a solution cross-plataform like this

Code:
const char dir_path[] = "c:\\temp\\cplusplus";

	boost::filesystem::path dir(dir_path);
	if(boost::filesystem::create_directory(dir)) {
		std::cout << "Success" << "\n";
	}
and you must include the following header : <boost/filesystem.hpp>
Thank you . i'm will try again . i just had to c++ language .
Try TBH1's code, it is correct
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us