S
shapper
Hello,
I have a filename and I need to check if it is of a specific type.
I have:
public static Boolean FileType(String filename, String[] types) {
return types.Length == 0 ? false : Array.Exists(types, s =>
String.Compare(s, Path.GetExtension(filename).TrimStart('.'), true) ==
0);
} // FileType
So if filename="document.pdf" and types = new string[] { "gif, pdf,
png, swf" } then it should return true because the document is a pdf
and pdf exists in types.
However, this is returning false.
I am a little bit confused on this. Should I add != 0 ... or maybe do
this in other way?
Thanks,
Miguel
I have a filename and I need to check if it is of a specific type.
I have:
public static Boolean FileType(String filename, String[] types) {
return types.Length == 0 ? false : Array.Exists(types, s =>
String.Compare(s, Path.GetExtension(filename).TrimStart('.'), true) ==
0);
} // FileType
So if filename="document.pdf" and types = new string[] { "gif, pdf,
png, swf" } then it should return true because the document is a pdf
and pdf exists in types.
However, this is returning false.
I am a little bit confused on this. Should I add != 0 ... or maybe do
this in other way?
Thanks,
Miguel