Some basic usage copy files, delete files

Recent problems encountered font on a drawing can not be displayed in the word which, later found to be missing several font files, making it impossible to read the correct character, based on this need for some basic file manipulation program.

1. give the font file included in the current program path (relative path)

static wchar_t path[MAX_PATH]
{
0
};
std::wstring filename(L"");
GetModuleFileName(NULL, (LPWSTR)path, sizeof(path));
filename += path;

At this point the path to get the name of the current program exe file where the address falls back under debug path

filename = filename.substr(0, filename.find_last_of(L"\\"));

2. determine whether the file under the specified directory file, if there is no copy operation

CopyFile (sourcepathname, targetpathname, FALSE); // file exists cover

3 copy to the specified directory, if the end of the run you want to delete, then call the delete operation

DeleteFile(filename);

Guess you like

Origin www.cnblogs.com/yx155029/p/12613683.html