When we write some programs that have destructive programs, we tend to cut and delete programs and so on.
Here is a brief explanation of the Cut copy deletion,
Copying of files
#include <Windows.h> #include <stdio.h> int main () { DWORD GetLastError; if (! Copyfilea ("C:\\1.txt", "F:\\1.txt", false)) { printf_s ("file copy failed \ n"); GetLastError = GetLastError (); return-1; } return 0; }
After the operation we can find that we can move the 1.txt from the C drive to the F drive.
The following function is explained below.
CopyFile function
BOOL WINAPI CopyFile ( _in_ lpctstr lpexistingfilename, _in_ lpctstr lpnewfilename, _in_ bool Bfailifexists );
First parameter: The name of a file that exists
Second parameter: The name of a new file
Third parameter: If there is a file with the same name true then no copy is made, False is overwrite.
Return value: Success returns a non-0 number, failure returns 0, and calling GetLastError () can get an error message.
Here is the deletion code for the file
#include <Windows.h> #include <stdio.h> int main () { DWORD GetLastError; if (! DeleteFileA ("C:\\1.txt")) { GetLastError = GetLastError (); printf_s ("c:\\1.txt delete failed"); return-1; } if (! DeleteFileA ("F:\\1.txt")) { GetLastError = GetLastError (); printf_s ("f:\\1.txt delete failed"); return-1; } printf_s ("Delete succeeded \ n"); return 0; }
DeleteFile function
BOOL WINAPI DeleteFile ( _in_ lpctstr lpfilename );
The parameter here is the name of the file to be deleted
return value:
The success returns a non-0 number, the failure returns 0, and the call to GetLastError () gets the error message.
Here is the cut of the file
#include <Windows.h> #include <stdio.h> int main () { if (! Movefilea ("C:\\1.txt", "F:\\1.txt")) { DWORD GetLastError; Getlasterror=getlasterror (); printf_s ("copy failed"); return-1; } printf_s ("Copy succeeded \ n"); return 0; }
The parameters and return values of the function are similar to the one above, and are not explained here.
The above is the C + + file Cut Copy deleted content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!