Judgment file
| The code is as follows |
Copy Code |
#include <fstream.h>void main () { Ofstream f ("C:\test.txt"); Open file Test.txt, for writing, if the file does not exist, create it first }
|
Cases
| The code is as follows |
Copy Code |
#include <iostream> #include <fstream> using namespace Std; #define FILENAME "Stat.dat" int main () { FStream _file; _file.open (filename,ios::in); if (!_file) { cout<<filename<< "not created"; } Else { cout<<filename<< "already exists"; } return 0; } |
Cases
Char szdirname[] = "File path";
| The code is as follows |
Copy Code |
CreateDirectory (Szdirname, NULL);
|
That's it, okay?
CreateDirectory
Function:
This function creates a new directory. If the underlying file system supports security in files and directories, the function applies a specified security Descri Ptor to the new directory.
(Create a new folder.) If the basic file system supports a security description on a file or folder, the function will apply the specified security description on the newly created folder.
Prototype:
| The code is as follows |
Copy Code |
BOOL CreateDirectory ( LPCTSTR Lppathname, Lpsecurity_attributes lpsecurityattributes );
|
Parameters:
Lppathname: A string that contains the path to the folder that will be created, with a length of not more than MAX_PATH.
lpSecurityAttributes: ignored, set to null
return value:
Returns Non-zero for success and zero for failure