-
December 13th, 2002, 06:11 AM
#1
how find files
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
-
December 13th, 2002, 06:19 AM
#2
files
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
-
December 13th, 2002, 06:20 AM
#3
files
hey, let me know, when you need more help
-
December 13th, 2002, 06:30 AM
#4
i used class CFindFile... there are some function FindFile() and FindNextFile() in this class... did you talked about this functions?
-
December 13th, 2002, 06:45 AM
#5
files
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
-
December 13th, 2002, 07:00 AM
#6
files
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
-
December 13th, 2002, 07:08 AM
#7
files
thanks, that is what i need
-
December 13th, 2002, 07:19 AM
#8
files
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
-
December 13th, 2002, 11:15 AM
#9
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.
-
December 14th, 2002, 04:24 AM
#10
Re: files
Originally posted by vovkin
i used this...
<snipped code>
this function goes in cycles why i don't know
As alpha137 mentioned you need to check for the '.' and '..' first otherwise you will recur infinitely...thus...
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();
};
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|