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!

How do I filter out files WITHOUT extension in Common Dialog?

Status
Not open for further replies.

kunmun23

Programmer
Oct 28, 2003
17
0
0
IN
Haven't been able to figure this out..a tricky one...
generally we use this
commondialog1.filter="EXCEL files (*.xls)|*.xls"
Commondialog1.showopen

this will just show the files with .xls extension in the directory.

Now I want to see only the files that have no extension and nothing else. so if there are two files 'abc.xls' and 'def' in the directory only 'def' should show up in the common dialog.

Help please.

Thanks in advance.
 
Without looking, I think I recall you need to use the wildcard *.

It's been a while, and I'm away from my development box... try it and see

[fish] No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!

Ever feel like you're banging your head against a tree? I did, so I cut down the tree.
 
Your wildcard is *. (INclude the period)

[fish] No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!

Ever feel like you're banging your head against a tree? I did, so I cut down the tree.
 
tried that..and many other combinations too...still can't get it to work...
I presume what you mean is

commondialog1.filter="*."

which doesn't work.
 
yes, that's what I meant... sorry it didn't work. I wish I had my laptop :(

[fish] No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!

Ever feel like you're banging your head against a tree? I did, so I cut down the tree.
 
it worked for the file list box (intrinsic component)

[fish] No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!

Ever feel like you're banging your head against a tree? I did, so I cut down the tree.
 
one workaround i found is

Do
CommonDialog1.ShowOpen ' show the dialog
Loop Until InStr(1, CommonDialog1.FileTitle, ".") = 0

don't like it though...would have been great if i could simply hide the files without the extensions...

Also any ideas on how can I dynamically change the DialogTitle of the common dialog to show the current filepath ?
 
I tried a number of combinations of filters and so on with the CommonDialog without success.
In your shoes, if this is something you need to do a lot (I take it adding extensions to these files is not an option)
then I'd be tempted to 'roll your own'
Using the Drive and Folder combos in combination with a file list box is the way I used to do it in Vb3.

Ditch the file list box, and simply fill a normal listbox with the results of searching the folder selected in the folder control.
There are a number of ways of doing that, but I use repeated calls to DIR() as I am more familiar with it.

 
Yes you guessed right. I cannot put an extension to the files.
Regarding using a filelistbox, I don't know if it would be possible.
I am using this common dialog in an activex script in a DTS package to prompt the user to choose a file before performing data transformations on it. I don't think it would be easy to create an object for a filelistbox. For common dialog I used comdlg32.dll to instantiate an object.

I even tried APIs and tweaked the customfilter and nfilterindex properties for the the getopenfilename API...couldn't get it to work.
 
Just stick "*." as the CommonDialog1.Filename instead of in Filter. A bit of a kludge, granted, but it works...
 
I couldn't get it to work...
I didn't set a default extension or filter
i just put
commondialog1.filename="*."
and none of the files showed up.
what am i doing wrong here..
can u explain please ..thanks.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top