我的代码有问题。我的 findfile 函数不显示实际名称,但显示文件夹名称。有谁知道是什么导致了这个问题。path 将是用户的下载文件夹,而 path1 是需要移动文件的位置。是的,我在那个目录中有文件。
代码(适用于窗户):
bool* pointer = &doen;
WORD wait = 2500;
string path1 = getCurrentPath();
char userName[10];
DWORD userNameSize = sizeof(userName);
GetUserName(userName, &userNameSize);
string path = path1.substr(0, 3);
path += "users\\";
path += userName;
path1 = path;
path += "\\downloads";
path1 += "\\documents\\xxxx";
char const* plaatsD = path.c_str();
char const* plaatsF = path1.c_str();
userNameSize = NULL;
WIN32_FIND_DATA ffd;
TCHAR szDir[MAX_PATH];
HANDLE hFind = INVALID_HANDLE_VALUE;
DWORD dwError=0;
string str;
string str2;
string str3;
char const* a;
char const* b;
StringCchCopy(szDir, MAX_PATH, plaatsD);
while (herhalen)
{
Sleep(wait);
hFind = FindFirstFile(szDir, &ffd);
if (INVALID_HANDLE_VALUE == hFind)
continue;
do
{
str = ffd.cFileName;
if (str.find("xxx") != string::npos)
{
str2 = path;
str2 += "\\" + str + ".b";
str3 = path1;
str3 += "\\" + str + ".b";
a = str2.c_str();
b = str3.c_str();
try
{
CopyFile(a, b, true);
}
catch (exception)
{
}
a = NULL;
b = NULL;
}
}
while (FindNextFile(hFind, &ffd) != 0);
}