473,581 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

openfiledialog filter ?

I would like to display two different types of files when bringing up
the OpenFileDialog, but I can't seem to figure out how to do this. I
can manage a single file type or all file types, but not just the ones
that I want. I used the statement before and though it displays the
*.csproj files it does not display the *.sln files.

openFileDialog. Filter = "Solution Files (*.sln) And Project Files
(*.csproj)|*sln ;*.csproj|All Files (*.*)|*.*";
Can someone tell me what I am doing wrong?

Z.K.
Sep 15 '08 #1
8 4085
Z.K. wrote:
I would like to display two different types of files when bringing up
the OpenFileDialog, but I can't seem to figure out how to do this. I
can manage a single file type or all file types, but not just the ones
that I want. I used the statement before and though it displays the
*.csproj files it does not display the *.sln files.

openFileDialog. Filter = "Solution Files (*.sln) And Project Files
(*.csproj)|*sln ;*.csproj|All Files (*.*)|*.*";
Can someone tell me what I am doing wrong?

Z.K.
I think you are looking for something like :
OpenFileDialog openFileDlg = new OpenFileDialog( );
openFileDlg.Fil ter = "Text Files (*.txt)|*.txt|A ll files (*.*)|*.*";
openFileDlg.Fil terIndex = 1;

this displays All files and .txt files
Sep 15 '08 #2
Navid wrote:
Z.K. wrote:
>I would like to display two different types of files when bringing up
the OpenFileDialog, but I can't seem to figure out how to do this. I
can manage a single file type or all file types, but not just the ones
that I want. I used the statement before and though it displays the
*.csproj files it does not display the *.sln files.

openFileDialog .Filter = "Solution Files (*.sln) And Project Files
(*.csproj)|*.s ln ;*.csproj|All Files (*.*)|*.*";
Can someone tell me what I am doing wrong?

Z.K.

I think you are looking for something like :
OpenFileDialog openFileDlg = new OpenFileDialog( );
openFileDlg.Fil ter = "Text Files (*.txt)|*.txt|A ll files (*.*)|*.*";
openFileDlg.Fil terIndex = 1;

this displays All files and .txt files

Actually, that is not what I am looking for. I can display single file
types or all file types just fine. It is only when I try to display
only certain file types that it does not work. Supposedly though it is
possible as I found this on a web site: MyFileOpen.Filt er = "ASCII files
(*.txt;*.log)|* .txt;*.log". I thought I was doing basically the same
thing, but I can not get it to work. I guess I will jsut have to use
all files for the time being until I figure it out.

Z.K.
Sep 15 '08 #3
On Mon, 15 Sep 2008 16:46:59 -0700, Z.K. <no****@nospam. netwrote:
Actually, that is not what I am looking for. I can display single file
types or all file types just fine. It is only when I try to display
only certain file types that it does not work. Supposedly though it is
possible as I found this on a web site: MyFileOpen.Filt er = "ASCII files
(*.txt;*.log)|* .txt;*.log". I thought I was doing basically the same
thing, but I can not get it to work. I guess I will jsut have to use
all files for the time being until I figure it out.
Yes. Unless you post the code you're actually using, it will be
impossible for anyone here to explain what you've done wrong.

Navid's reply was accurate even if simpler than what you want, and the
MSDN documentation is accurate as well (saying substantially the same
thing), as is the web site where you found yet another example. All of
these examples are correct. So, if your code doesn't do what those
examples say they do, you haven't followed the example correctly.

But if you don't post the code, no one could possibly know what mistake
you've made, and you will "just have to use all files for the time
being". I certainly agree with that. :)

Pete
Sep 16 '08 #4
In what you posted, there is no dot (.) between the * and the sln. You have
*SLN. Try fixing that.

"Z.K." <no****@nospam. netwrote in message
news:en******** ******@TK2MSFTN GP02.phx.gbl...
>I would like to display two different types of files when bringing up the
OpenFileDialog , but I can't seem to figure out how to do this. I can
manage a single file type or all file types, but not just the ones that I
want. I used the statement before and though it displays the *.csproj files
it does not display the *.sln files.

openFileDialog. Filter = "Solution Files (*.sln) And Project Files
(*.csproj)|*sln ;*.csproj|All Files (*.*)|*.*";
Can someone tell me what I am doing wrong?

Z.K.
Sep 16 '08 #5
Peter Duniho wrote:
On Mon, 15 Sep 2008 16:46:59 -0700, Z.K. <no****@nospam. netwrote:
>Actually, that is not what I am looking for. I can display single
file types or all file types just fine. It is only when I try to
display only certain file types that it does not work. Supposedly
though it is possible as I found this on a web site: MyFileOpen.Filt er
= "ASCII files (*.txt;*.log)|* .txt;*.log". I thought I was doing
basically the same thing, but I can not get it to work. I guess I
will jsut have to use all files for the time being until I figure it out.

Yes. Unless you post the code you're actually using, it will be
impossible for anyone here to explain what you've done wrong.

Navid's reply was accurate even if simpler than what you want, and the
MSDN documentation is accurate as well (saying substantially the same
thing), as is the web site where you found yet another example. All of
these examples are correct. So, if your code doesn't do what those
examples say they do, you haven't followed the example correctly.

But if you don't post the code, no one could possibly know what mistake
you've made, and you will "just have to use all files for the time
being". I certainly agree with that. :)

Pete

Oops, I thought I had. I figured it out anyway. I knew it was simple I
just got the syntax a bit wrong. I did it like this:
openFileDialog. Filter = "Solution and Project Files
(*.sln;*.csproj )|*.sln;*.cspro j|" + "All files (*.*)|*.*";

Thanks anyway though.

Z.K.
Sep 16 '08 #6
Family Tree Mike wrote:
In what you posted, there is no dot (.) between the * and the sln. You
have *SLN. Try fixing that.

"Z.K." <no****@nospam. netwrote in message
news:en******** ******@TK2MSFTN GP02.phx.gbl...
>I would like to display two different types of files when bringing up
the OpenFileDialog, but I can't seem to figure out how to do this. I
can manage a single file type or all file types, but not just the ones
that I want. I used the statement before and though it displays the
*.csproj files it does not display the *.sln files.

openFileDialog .Filter = "Solution Files (*.sln) And Project Files
(*.csproj)|*sl n ;*.csproj|All Files (*.*)|*.*";
Can someone tell me what I am doing wrong?

Z.K.

Yes, I figure that out, but it did not help. I figured it out anyway as
in openFileDialog. Filter = "Solution and Project Files
(*.sln;*.csproj )|*.sln;*.cspro j|" + "All files (*.*)|*.*";

Thanks,

Z.K.
Sep 16 '08 #7
On Mon, 15 Sep 2008 17:34:31 -0700, Z.K. <no****@nospam. netwrote:
Oops, I thought I had.
Well, you posted one line of code. Granted, it was an incorrect line of
code, but it's impossible to know for sure that the error in that line is
the one causing you trouble, when you haven't posted a complete code
sample.
I figured it out anyway. I knew it was simple I just got the syntax a
bit wrong. I did it like this: openFileDialog. Filter = "Solution and
Project Files (*.sln;*.csproj )|*.sln;*.cspro j|" + "All files (*.*)|*.*";
How would that be different from:

openFileDialog. Filter = "Solution and Project Files
(*.sln;*.csproj )|*.sln;*.cspro j|All files (*.*)|*.*";

?

Pete
Sep 16 '08 #8
The original post dropped the . in *.sln, and had a space before the
semi-colon after sln. Once those were fixed, the code worked fine for me.
I think a few things were changed before you saw the post.
"Peter Duniho" <Np*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
On Mon, 15 Sep 2008 17:34:31 -0700, Z.K. <no****@nospam. netwrote:
>Oops, I thought I had.

Well, you posted one line of code. Granted, it was an incorrect line of
code, but it's impossible to know for sure that the error in that line is
the one causing you trouble, when you haven't posted a complete code
sample.
>I figured it out anyway. I knew it was simple I just got the syntax a
bit wrong. I did it like this: openFileDialog. Filter = "Solution and
Project Files (*.sln;*.csproj )|*.sln;*.cspro j|" + "All files (*.*)|*.*";

How would that be different from:

openFileDialog. Filter = "Solution and Project Files
(*.sln;*.csproj )|*.sln;*.cspro j|All files (*.*)|*.*";

?

Pete
Sep 16 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5707
by: Lina | last post by:
Hello, I wanted to ask if anyone can help me complete the following code. I found this example while searching through help documnets. What i want to achieve is to open a dialog box that lets the user select an images file. I am using the openFileDialog control. Here is what i have done so far for the onlick event for the button...
4
7987
by: Nagachandra Sekhar Grandhi | last post by:
I am facing a problem with OpenFileDialog. It is as follows. I opened OpenFileDialog dialog box and selected a folder in it. After selecting the folder when i tried to delete the same folder in Explorer i am getting error saying that cannot delete that folder as some process is using it. After that i selected a file from the same folder in...
4
6161
by: Michael Grosse | last post by:
I've conquered a very strange behaviour that I cannot account for logically and therefore seek help in this Discussion Group. I'm currently developing 2 applications and intend to use the standard open File Dialog with the code snippet found below. The code snippet is exactly the same in both applications but the behaviour is fundamentally...
6
2998
by: barbara_dave | last post by:
Hi, All, I want to use the openfiledialog to open different extension files in different directory( only one type files at one time). I set the OpenFiledialog InitialDirectory and Filter property for ".dat" files at first time, it works. When I try to use openfiledialog to set different InitialDirectory an different Filter property for...
4
3614
by: Mike | last post by:
I need help understanding why the following code is not working correctly. When run, I can open .mdb files by changing the filter option to "All Files (*.*)" but while "Access Database (mdb.*)" is selected no db files are listed in the OpenFileDialog box.... ------------------------------------- Private Sub btnDatabase_Click(ByVal sender As...
8
6074
by: marcus.kwok | last post by:
I am having a weird problem and I have can't figure out why it is happening. I create an OpenFileDialog and set a filename filter. When the dialog first opens, the filter works correctly, and only the files I want to see appear in the file list box. When I change the filter to one of the other filters, all the files in the list disappear. ...
1
2327
by: Shilpa | last post by:
Hi, I have a OpenFileDialog on my windows form whose filter is *.*. I want the users to be able to further filter the files by giving *.doc or *.zip etc in the "file name" field of the dialog (Just like it happens in the open file dialog of MS Word) Currently, if the user enters a wild card character in the file name field, it is throwing...
6
872
by: Mike | last post by:
Hello all, I'm trying to work with the openfiledialog and being new to vb and vb.net I'm having some problems. Wherever I have Me.OpenFileDialog1 I keep getting the following error: C:\Visual Studio Projects\ImageLoad\OpenFileDialog1.vb(66): 'OpenFileDialog1' is not a member of 'ImageLoad.OpenFileDialog1'. Can someone please tell me why...
0
7869
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8151
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8176
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6555
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5677
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5365
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3806
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3830
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1404
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.