bool __fastcall SearchSomeFile(String path, String FileName, String &tPath)
{
AnsiString dir, fn, subPath;
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.cFileName[0]!=_T('.') || lstrlen(wfd.cFileName)>2) &&
wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {//directory
subPath = wfd.cFileName;
subPath = path + subPath;
if (SearchDxfFile(subPath, FileName, tPath)) {
FindClose(hSrch);
return true;;
}
}
else { // file
fn = wfd.cFileName;
if (fn == FileName) {
tPath = path;
FindClose(hSrch);
return true;
}
}
bResult = FindNextFile(hSrch, &wfd);
}
FindClose(hSrch);
return false;
}
|
특정 폴더 내부에 있는 파일을 검색하는 함수이다.
내부 폴더가 있더라도 그 폴더까지 검사하도록 했다.
tPath에 파일이 있는 위치(폴더명)가 들어간다.
LIST
'Borland' 카테고리의 다른 글
| The new and delete Operators with multi-dimensional arrays (다차배열) (0) | 2011.01.18 |
|---|---|
| Shift의 의미 (0) | 2011.01.13 |
| WideString 결과값과 HTML에서 표기 되는 유니코드값의 차이 (0) | 2010.04.22 |
| HexStr을 TColor로 변경 하는 함수 (0) | 2010.04.22 |
| Excel ColumnWidth 변경 매크로 (0) | 2010.02.01 |