Its complicated to explain, but easy to show.
I created a little utility to move files around from my download directories.
It reads from an XML file the following attributes:
Extension (.avi, .mp3, etc)
Action (Copy, Move, Delete, etc)
Destination (where to put it if moved or copied)
Now this is easy, one record in an XML document per extension. I load the program, it loads this information into a user defined data type and I throw it into a HashTable, using the extension as the key. Then I compare each files extension in the directory. If its ".avi" then it pulls up ".avi" from the hashtable.
Ive been getting random files which are harder now: ".001, .005, .050, .R05, .P29", etc.
IE, they follow patterns, but there are many different instances of them. For this reason I was thinking of holding Regular Expressions instead of just plain strings.
I was thinking of somehow using a string of the Regular Expression as the Key in the HashTable... something like this: (I think this is good)
"[.][0-9][0-9][0-9]"
This should match up to "." and any three numbers... basically .001 to .999
Something similar could be done with "[.R][0-9][0-9]" for RAR archives.
If I can figure out how to do Regular Expressions as the Key and do a comparison of the filename (fullname + extension), I could really get some filtering action going on.
Could anyone be of any help on this?
The best I can think of logically (I dont know the syntax) would be to cycle through the HashTable for each file and compare each of the Keys to the filename. Im sure this would be a fairly large performance hit compared to just trying to get the key and either it doesnt exist or it does and has instructions attached.
I created a little utility to move files around from my download directories.
It reads from an XML file the following attributes:
Extension (.avi, .mp3, etc)
Action (Copy, Move, Delete, etc)
Destination (where to put it if moved or copied)
Now this is easy, one record in an XML document per extension. I load the program, it loads this information into a user defined data type and I throw it into a HashTable, using the extension as the key. Then I compare each files extension in the directory. If its ".avi" then it pulls up ".avi" from the hashtable.
Ive been getting random files which are harder now: ".001, .005, .050, .R05, .P29", etc.
IE, they follow patterns, but there are many different instances of them. For this reason I was thinking of holding Regular Expressions instead of just plain strings.
I was thinking of somehow using a string of the Regular Expression as the Key in the HashTable... something like this: (I think this is good)
"[.][0-9][0-9][0-9]"
This should match up to "." and any three numbers... basically .001 to .999
Something similar could be done with "[.R][0-9][0-9]" for RAR archives.
If I can figure out how to do Regular Expressions as the Key and do a comparison of the filename (fullname + extension), I could really get some filtering action going on.
Could anyone be of any help on this?
The best I can think of logically (I dont know the syntax) would be to cycle through the HashTable for each file and compare each of the Keys to the filename. Im sure this would be a fairly large performance hit compared to just trying to get the key and either it doesnt exist or it does and has instructions attached.