Oct 3, 2008 at 7:18am UTC
Hi All,
I am using DirectoryInfo class to find a specific file from all the locations in system.
For that i have written the following code,
My Code:
<code>
using namespace System;
using namespace System::IO;
void samplefile::FindFile(CString startingDir, CString fileName, vector<CString> foundFiles)
{
DirectoryInfo* dirInfo = new DirectoryInfo(startingDir);
if (dirInfo->Exists) // make sure directory exists
{
FileInfo* files[] = dirInfo->GetFiles();
for (int i = 0; i < files->Length; i++)
{
String* currFileName = files[i]->ToString();
if (0 == String::Compare(currFileName, fileName, true))
{
foundFiles.push_back(files[i]);
}
}
DirectoryInfo* subDirs[] = dirInfo->GetDirectories();
for (int i = 0; i < subDirs->Length; i++)
{
String* dirName = subDirs[i]->FullName;
FindFile(dirName, fileName, foundFiles);
}
}
}
</code>
But i am getting the following error:
error C2653: 'System' : is not a class or namespace name
I tried in the net regarding this error. It shows that i need to enable common runtime support.
I really don't know how to do that....
I am using Visual C++ 6.0.
Please help me out.
Oct 3, 2008 at 9:01am UTC
It seems like you are getting confused between C++ and c# namespaces and directives.
Oct 3, 2008 at 9:29am UTC
Hi
Actually I don' know C#, But i need to find the specific file from all the locations, I tried with CFindFile(), In that if i mention the specific path only, it is finding the file,
Give me some suggessions to do that.
Thanks..