E
Edwin
What I am trying to do is come up with a way to determine how many unique
extensions there are within a directory and its sub directories. Within the
loop that recurses root folder, I am attempting to use a SortedList. Below
is the code:
private System.Collections.SortedList _ArrayListOfExtensions = new
SortedList(new CaseInsensitiveComparer());
System.Int32 myIndexOfValue = -1;
myIndexOfValue =
this._ArrayListOfExtensions.IndexOfKey(myCurrentFile.Extension.ToLower());
if (myIndexOfValue == -1)
{
this._ArrayListOfExtensions.Add(myCurrentFile.Extension.ToLower(), 1);
}
The Exception error that I am getting is:
"Unable to cast object of type 'System.Collections.DictionaryEntry' to type
'System.String'."
Any help would be appreciated as to how to correct this error. Also, if you
know of a better way (I have tried several) to accomplish the above, I am
open to your suggestions.
The results should be similar to:
15 .docx
17 .doc
14 .txt
7 .exe
etc...
Thanks!
Edwin
extensions there are within a directory and its sub directories. Within the
loop that recurses root folder, I am attempting to use a SortedList. Below
is the code:
private System.Collections.SortedList _ArrayListOfExtensions = new
SortedList(new CaseInsensitiveComparer());
System.Int32 myIndexOfValue = -1;
myIndexOfValue =
this._ArrayListOfExtensions.IndexOfKey(myCurrentFile.Extension.ToLower());
if (myIndexOfValue == -1)
{
this._ArrayListOfExtensions.Add(myCurrentFile.Extension.ToLower(), 1);
}
The Exception error that I am getting is:
"Unable to cast object of type 'System.Collections.DictionaryEntry' to type
'System.String'."
Any help would be appreciated as to how to correct this error. Also, if you
know of a better way (I have tried several) to accomplish the above, I am
open to your suggestions.
The results should be similar to:
15 .docx
17 .doc
14 .txt
7 .exe
etc...
Thanks!
Edwin