473,671 Members | 2,341 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 1881
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
5711
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...
1
5777
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 to change the directory in the OpenFileDialog! Is there a way to implement this? Please let me know. Thanks, Paras Wadehra
3
1746
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
1535
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 change the directory in the OpenFileDialog! Is there a way to implement this? Please let me know. Thanks, Paras Wadehra
7
55776
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
3464
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 extension of the file, so i no longer need the openfiledialog, thus i am using openfiledialog1.reset() method to reset it. (i have also tried openfiledialog.dispose() with no results) The problem i am encountering is that the folder in which the...
1
2677
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 Win32_Product. For this i need to give the Patch location by using OpenFileDialog Control.. how to do this... Thanks in advance..
0
826
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 should belong to System.Web.UI.Webcontrol (and not HTMLControl). Please Advice. Thanks, Rivka
0
8478
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8397
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8919
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8599
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6230
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4225
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2813
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 we have to send another system
2
2052
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.