473,511 Members | 12,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C#NET2008 OpenFileDialog Control

126 New Member
Hullo my lovely friends,
I am back asking for help. Please help me.
I am trying to use OpenFileDialog control to display specific files with .XML extension and prompt the users to select only file with extension .XML

Apparently I don't know how to only display specific files with .XML on the FileDialog display screen. Instead it display all the files kept in the Folder. It's causing confusion to the users as the folder contained more than 540 files.

Here are my coding that is not displaying only specific files with .XML extension

Expand|Select|Wrap|Line Numbers
  1.  String strFileNameNPath
  2. private void btnTemplate_Click(object sender, EventArgs e)
  3.  {
  4.    //create an OpenfleDialog
  5.    System.Windows.Forms.OpenFileDialog dlgOpen = new System.Windows.Forms.OpenFileDialog();
  6.  
  7.    //set properties for dlgOpen
  8.    dlgOpen.Title =  "Select XML File ;
  9.    dlgOpen.ShowReadOnly = true;
  10.    dlgOpen.Multiselect = false;
  11.  
  12.    //display the dialog and return results
  13.    if (dlgOpen.ShowDialog() == DialogResult.OK)
  14.      {
  15.        strFileNameNPath = dlgOpen.FileName;
  16.        this.txtTemplate.Text = strFileNameNPath;
  17.       }
  18.   Else
  19.       {
  20.     messagebox.show(“Your cancel XML selection”)
  21.       }
  22.  } 

Thank you for helping me. Yaaa.....Hooo.......
Have a Good Day,
Cheers,
Lennie
Oct 27 '10 #1
3 1872
GaryTexmo
1,501 Recognized Expert Top Contributor
Look up the MSDN article for OpenFileDialog. There's a Filter property that should help you out.

Good luck!
Oct 27 '10 #2
lenniekuah
126 New Member
Gary
Prior to posting my problem here I did tried to look at MSDN and couldn't find the article as I don't know the URL Link Address.

What what is the URL Link address ?
Oct 28 '10 #3
GaryTexmo
1,501 Recognized Expert Top Contributor
I just searched off the main page.
OpenFileDialog class: http://msdn.microsoft.com/en-us/libr...iledialog.aspx

Filter property: http://msdn.microsoft.com/en-us/libr...og.filter.aspx

Code example on that last page. Give it a try and let us know if you have any troubles.

*Edit: If it helps, when I search MSDN I just typed the class name. It suggested the filter property as the second hit, the first was the class itself. If I'm googling, I usually search with "C# MSDN OpenFileDialog" replacing OpenFileDialog with whatever class name I'm interested in. Another helpful tip is to just google "C# <my problem here>", I find that generates some good hits.
Oct 28 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
5698
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...
1
5748
by: Paras Wadehra | last post by:
Hi Friends, Can anyone please help me with the OpenFileDialog Control in VB.Net? I want the user to be restricted to a particular folder only for selecting a file, i.e. they should not be able...
3
1738
by: LEE | last post by:
I used an OpenFileDialog control, it was not focused every time it was called. How to focus it? Thanks
1
1510
by: Paras Wadehra | last post by:
Hi Friends, Can anyone please help me with the OpenFileDialog Contol in VB.Net? I want the user to be restricted to a particular folder only for selecting a file, i.e. they should not be able to...
7
55762
by: Sakharam Phapale | last post by:
Hi All, I want to give option to user for selecting directory, just like for selecting file using OpenFileDialog control. How to make it possible?
3
3453
by: juststarter | last post by:
Hello all, I am using an openFileDialog box to select a file (in order to insert it in a database). When the file is selected i am filling a few textboxes with the actual path, filename and...
1
2667
by: DKn | last post by:
Hi, How to get the Files from Remote system by using OpenFileDialog control in C#.Net windows application? Actually i am trying to do Software upgradation for a remote system by using...
0
822
by: Rivka | last post by:
Hello, In my asp.net application, I'd like to have the affect of opendialog control to get a folder name (this cannot be realized using fileupload) . Another requirent of my software is that it...
0
7148
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7367
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,...
1
7089
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5673
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,...
1
5072
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...
0
4743
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...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
451
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.