Click to See Complete Forum and Search --> : Compare Function..
somu0915
February 27th, 2008, 08:28 AM
Hi,
I have a array of Strings which stores various filenames..
Which method can I use to compare it so that I know that it is an exe file??
Please describe by few lines of code..
Skizmo
February 27th, 2008, 08:52 AM
check the extension :
if (String.Right (3) == "exe")
somu0915
February 27th, 2008, 09:02 AM
Sorry but I am using C++/CLI, and there is no Right method as u have suggested..
Here is a sample of my code:
String^ myStr = "C:\windows\system32\abc.exe"
now can u write the code for this to compare whether it is a exe file??
GCDEF
February 27th, 2008, 09:24 AM
Try the managed C++ forum.
somu0915
February 27th, 2008, 09:35 AM
Hi,
I have a array of Strings which stores various filenames..
Which method can I use to compare it so that I know that it is an exe file??
Here is a sample of my code:
String^ myStr = "C:\windows\system32\abc.exe"
Please describe by few lines of code..
TheCPUWizard
February 27th, 2008, 10:35 AM
1) (As GCDEF pointed out), this has NOTHING to do with C++. It is a question about the CLI and CLR BCL.
2) Of course you can get the Right most characters of a string (Length and SubString :rolleyes: )
3) Why not just use the FileSystemInfo.Extension Property :confused:
darwen
February 27th, 2008, 04:53 PM
Personally I'd use the System::IO::Path class which contains all sorts of static methods for file manipulation e.g.
String^ myStr = "C:\windows\system32\abc.exe"
// use String::Compare to do a case insensitive comparison
if (System::String::Compare(System::IO::Path::GetExtension(myStr), ".exe", true) == 0)
{
// it's an exe
}
Darwen.
somu0915
February 28th, 2008, 12:12 AM
Personally I'd use the System::IO::Path class which contains all sorts of static methods for file manipulation e.g.
String^ myStr = "C:\windows\system32\abc.exe"
// use String::Compare to do a case insensitive comparison
if (System::String::Compare(System::IO::Path::GetExtension(myStr), ".exe", true) == 0)
{
// it's an exe
}
Darwen.
Hey thanx Darwen,
That was a real cool answer..
Marc G
February 28th, 2008, 08:47 AM
[ moved thread ]
Marc G
February 28th, 2008, 08:48 AM
[ merged thread ]
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.