-
January 23rd, 2009, 02:59 PM
#1
.net to MFC conversion
Hey I put together this function in .NET and now I need it in MFC. Any help or ideas would be great!
DirectoryInfo^ dirInfo = gcnew DirectoryInfo(sDir);
if (dirInfo->Exists) // make sure directory exists
{
// Get a reference to each directory in that directory.
array<FileInfo^>^ files;
files = dirInfo->GetFiles();
for (int i = 0; i < files->Length; i++)
{
String^ currFileName = files[i]->ToString();
shortName = fName;
String^ currFileType = files[i]->Extension;
DateTime currFileDate = files[i]->CreationTime;
for (int j = 0; j < 9; j++)
{
//Console::WriteLine("j= "+j);
if (j==0)
fType=".mpg";
if (j==1)
fType=".txt";
if (j==2)
fType=".avi";
if (j==3)
fType=".divx";
if (j==4)
fType=".m1v";
if (j==5)
fType=".mov";
if (j==6)
fType=".wmv";
if (j==7)
fType=".asf";
if (j==8)
fType=".mp4";
if (0 == String::Compare(currFileType, fType, true))
{
//test_sw->WriteLine("currFileDate="+currFileDate+" startval="+startVal+" endVal="+endVal);
if (currFileDate >= startVal && currFileDate <= endVal)
foundFiles->Add(files[i]);
}
}
}
array<DirectoryInfo^>^subDirs = dirInfo->GetDirectories();
for (int i = 0; i < subDirs->Length; i++)
{
String^ dirName = subDirs[i]->FullName;
sDir = dirName;
FindFile();
}
}
else
//Console::WriteLine("Does not exist");
-
January 23rd, 2009, 03:10 PM
#2
Re: .net to MFC conversion
^ is a pointer (*). gcnew manages all you memory allocations, so you have to do them yourself (new/delete/new[]/delete[]). The rest is a lot of the same. Simply google for the functions you have in .Net and look for the equivalent function in MFC (or ask us )
-
January 23rd, 2009, 03:11 PM
#3
Re: .net to MFC conversion
-
January 23rd, 2009, 04:43 PM
#4
Re: .net to MFC conversion
Originally Posted by Alin
Hey Alin, that was a great help. I've been running through compiling line by line and its been going great. Until I got to this line.
strExtension = FileInformation.cFileName;
This is the error I get:
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'WCHAR [260]' (or there is no acceptable conversion)
c:\program files\microsoft visual studio 9.0\vc\include\xstring(914): could be 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>:perator =(const std::basic_string<_Elem,_Traits,_Ax> &)'
Is there a conversion? A way around this?
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
|