http://msdn2.microsoft.com/en-us/library/aa365740.aspx
void __fastcall TMainDataForm::RenameForProductID(AnsiString path, AnsiString add)
{
AnsiString dir, fn;
HANDLE hSrch;
WIN32_FIND_DATA wfd;
bool bResult = true;
int length = path.Length();
if (path[length-1] != '\\') path += "\\";
dir = path + "*.*";
hSrch = FindFirstFile(dir.c_str(), &wfd);
while(bResult) {
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {}//directory
else { // file
fn = wfd.cFileName;
RenameFile(path+fn, path+add+fn);
}
bResult = FindNextFile(hSrch, &wfd);
}
FindClose(hSrch);
}
//---------------------------------------------------------------------------
void __fastcall TMainDataForm::CopyToSubDirectory(AnsiString path, AnsiString subName)
{
AnsiString dir, fn, subdir;
HANDLE hSrch;
WIN32_FIND_DATA wfd;
bool bResult = true;
int length = path.Length();
if (path[length-1] != '\\') path += "\\";
dir = path + "*.*";
subdir = path + subName + "\\";
DWORD attr = GetFileAttributes(subdir.c_str());
if (!(attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY)) {
if (!CreateDirectory(subdir.c_str(), NULL))
{
Application->MessageBox("The Directory can not be created.", "Warning", MB_OK);;
return;
}
}
hSrch = FindFirstFile(dir.c_str(), &wfd);
while(bResult) {
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {}//directory
else { // file
fn = wfd.cFileName;
CopyFile((path+fn).c_str(), (subdir+fn).c_str(), false);
}
bResult = FindNextFile(hSrch, &wfd);
}
FindClose(hSrch);
}
//---------------------------------------------------------------------------
'Borland' 카테고리의 다른 글
HOWTO: 파일을 Internet Information Server에 업로드하는 방법 (308) | 2008.01.17 |
---|---|
예제: POST로 많은 양의 데이터를 요청할 때 HttpSendRequestEx를 사용하는 방법 (0) | 2008.01.17 |
파일 존재 유무/ Size 알아오기 (0) | 2008.01.04 |
C++ Dev Journal / HTML user interface (31) | 2007.11.29 |
ActionToolBar에서 버튼 추가는 어떻게 하나요? (0) | 2007.11.29 |