How find files in folder with subfolders by mask and copy this files in other folder with the same subfolders?
What class?
or maybe write code, plz :)
Printable View
How find files in folder with subfolders by mask and copy this files in other folder with the same subfolders?
What class?
or maybe write code, plz :)
hey, you can use the api, there' re functions to search files, code a few lines, you' ll be able to write your own class that solves your problems, use FindFirstFile(), FindNextFile(), use the structure, they put their returns in, so you can handle files and folders
hey, let me know, when you need more help
i used class CFindFile... there are some function FindFile() and FindNextFile() in this class... did you talked about this functions?
they' ve got the same name, but i' m not shure that they are the same, the mfc encapsulate the api functions, so they might be identical, did you get any results, are you going to solve it
hey, Andreas Masur gave me that when i was trying to detect if a file exists or not:
CString szPath("c:\\windows");
DWORD dwAttr = GetFileAttributes(szPath);
if (dwAttr == 0xffffffff)
{
DWORD dwError = GetLastError();
if (dwError == ERROR_FILE_NOT_FOUND)
{
// file not found
}
else if (dwError == ERROR_PATH_NOT_FOUND)
{
// path not found
}
else if (dwError == ERROR_ACCESS_DENIED)
{
// file or directory exists, but access is denied
}
else
{
// some other error has occured
}
}
else
{
if (dwAttr & FILE_ATTRIBUTE_DIRECTORY)
{
// this is a directory
}
else
{
// this is an ordinary file
}
}
maybe that is another start for you
thanks, that is what i need :D
i used this...
void CBackup::FindFileBckp( CString path, CString mask )
{
CFileFind finder;
path+=_T( "\\" )+mask;
BOOL bFinding = finder.FindFile( path );
while( bFinding )
{
bFinding=finder.FindNextFile();
if( finder.IsDirectory() )
{
CString str = finder.GetFilePath();
FindFileBckp( str, mask );
}
else
{
CString article=path;
int len=article.GetLength();
int temp=article.Delete( 0,len );
temp=article.Delete( temp-4,3 );
CopyFileBckp( finder.GetFilePath(),myPath,article );
}
}
finder.Close();
};
this function goes in cycles :( why i don't know
Hi,
I can imagine that depending on your mask FindFile and FindNextFile will find the "." and ".." directories, too.
As long as you have no special handling for these you will get an endless loop.
As alpha137 mentioned you need to check for the '.' and '..' first otherwise you will recur infinitely...thus...Quote:
Originally posted by vovkin
i used this...
<snipped code>
this function goes in cycles :( why i don't know
Code:void CBackup::FindFileBckp( CString path, CString mask )
{
CFileFind finder;
path += _T("\\") + mask;
BOOL bFinding = finder.FindFile(path);
while(bFinding)
{
bFinding = finder.FindNextFile();
if(finder.IsDots())
continue;
if(finder.IsDirectory())
{
CString str = finder.GetFilePath();
FindFileBckp(str, mask);
}
else
{
CString article = path;
int len = article.GetLength();
int temp = article.Delete(0, len);
temp = article.Delete(temp - 4, 3);
CopyFileBckp(finder.GetFilePath(), myPath, article);
}
}
finder.Close();
};