File Operations in the File Manager
Next we will introduce some file-related operations, which are some APIs provided by Microsoft Windows.
• File Replication
Bool copyfile (maid, maid );
Copy the file or directory lpexistingfilename to the file or directory lpnewfilename. If bfailifexists is true, if a file with the same name as lpnewfilename exists, the copy operation is not performed and an error is returned. If bfailifexists is false, the file with the same name as lpnewfilename is overwritten.
• File Movement
Bool movefile (maid, maid );
Move the lpexistingfilename file or directory to the file or directory lpnewfilename.
• File opening
Open a specified file or run the specified application.
Hinstance ShellExecute (hwnd, lpctstr lpoperation, lpctstr lpfile,
Lptstr lpparameters, lptstr lpdirectory, int nshowcmd );
• File Search
The following three API functions are required to search for a file:
• Handle findfirstfile (lptstr lpfilename, lpwin32_find_data lpfind filedata );
Find the first file that complies with the lpfilename rule.
• Bool findnextfile (handle hfindfile, lpwin32_find_data lpfindfiledata );
Find the next file that complies with the lpfilename rule.
• Bool findclose (handle hfindfile );
After the search is completed, release the resources used for the search. This is not necessary, but if the reader wants to be a qualified programmer, this must be done, A necessary code for programmers is to keep in mind the recycling of resources, which will lead to adverse consequences due to the absence of recycling resources. I will not go into details here. These negative cases can be seen everywhere.