Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Illegal Names with the DirectoryInfo object. + visualbasic.dir command

Status
Not open for further replies.

NoCoolHandle

Programmer
Apr 10, 2003
2,321
0
0
US
Hi..
first (to solicit sympathy) I work with a bunch of MAC people who do all sorts of stupid (non-windows type) things.

Last week I asked one of them if they had any images of X - yeah a bunch of graphic artists.

After digging through a big 3 ring folder, I was handed 3 cd's that had the archived images stored on them. This caused me to have instant sympathy as this sort of search happens often. SO>>>> enter the programmer in me. Build an app that reads the cds file structure and then addes any file's name/size and other important info into a sqldatabase that can then be queried via a webapp.

Well it only took about 40 cds to bump into my first hickup - the archiving process recorded 0 files. Being curious I dug a bit deeper and found that the directoryinfo object was terminating due to an "illegal filename" - it turned out that someone had built a directory called
AMOS_Label_2x4[red]"[/red].job
.

This caused 2 problems
1. it wouldn't list any files using the fileinfo's recursive file search
2. it wouldn't let me list any of the directorys in the drive unless I did a "*." search - which caused it to miss directories that were named like
SPLASH_WW_GatweayShopAd.job

Enter new options...
Remembering back to the days of VB4 (yes I am that old:), we used the dir command to search the drive for file or directory listings. After a very quick look at using the process.run command to run dir into a cmd window and discounting it as usefull as the only way it seemed to be usefull was to send the output to a textfile and then force me to read the contents of the text file (too many steps)

Tha caused me to dig into the visualbasic namespace and found the good old visualbasic.[blue]dir[/blue] command worked like it did in the days of VB x.x

Now the only probem is that although I can read these "MAC Built Direcotries" When a dir is executed it also returns files. (picky aren't i)

SO>>>>> here is the question (sorry it took so long)
is there any way to eliminate from the listing any files..
- One thought is that filesize might be an indicator, but the dir command doesnt seem to do anything other than list the name.

Thanks for reading this far and any clues or ideas are welcome.


Rob

 
Just thought of alternative... (just don't know how to do it.)

Is it possible to "escape" a bad character using the directoryinfo object? or force it to use 8.3 naming?

That might solve the issue.

Thanks in advance.
 
Update:

the visualbasic.dir object/method proved to not perform as I had hoped. (it also required a seperate thread to execute for each subsequent call to a subdirectory)

there are directorys that have periods in them and these end up becomming invisible.

That puts me back to reading the results of a dir command sent to the cmd window. --- maybe just easier to tell those sinking mac users it is their faults that it wont work :)

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top