473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

SaveFileDialog Box Filetype Filter

I have a pretty quick question. When adding a saveFileDialog box, how can I filter it so it only searches for certain file types. Namely XML. If found something online that looked like:

saveFileDialog1.Filter = "DAT31-8 Files (*.N31)|*.xml|All Files (*.*)|*.*" ;

but editting that does not really help me any

I imagine it is a fairly easy fix, but can not find any documentation on it. Thanks for your help in advance.
May 5 '10 #1

✓ answered by Plater

The filter string isn't all that intuitive.
Basically it's making pairs by the | divider
Consider this filter string: "All Files (*.*)|*.*"
The first part "All Files (*.*)" is the displayed portion in the filter selection of the dialog box, while the second part "*.*" is the actual filter supplied.
You need two parts for each entry you want in the filter selection.

In your case, for 3 entries you might want:
Expand|Select|Wrap|Line Numbers
  1.  
  2. saveFileDialog1.Filter = "DAT31-8 Files (*.N31)|*.N31|XML Files (*.XML)|*.xml|All Files (*.*)|*.*" ;
  3.  
  4.  

1 2901
Plater
7,872 Expert 4TB
The filter string isn't all that intuitive.
Basically it's making pairs by the | divider
Consider this filter string: "All Files (*.*)|*.*"
The first part "All Files (*.*)" is the displayed portion in the filter selection of the dialog box, while the second part "*.*" is the actual filter supplied.
You need two parts for each entry you want in the filter selection.

In your case, for 3 entries you might want:
Expand|Select|Wrap|Line Numbers
  1.  
  2. saveFileDialog1.Filter = "DAT31-8 Files (*.N31)|*.N31|XML Files (*.XML)|*.xml|All Files (*.*)|*.*" ;
  3.  
  4.  
May 6 '10 #2

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

Similar topics

4
by: Michael A. Covington | last post by:
I've just determined, by experimenting, that regardless of its Filter and DefaultExt properties, a SaveFileDialog will let you save the file with *any* registered extension. For instance, if you...
3
by: josh | last post by:
How do I make it actually save or open a file? It only opens the dialogs. What do I type to get it to save? Here's what I have so far: Public Class frmMainApp Inherits...
2
by: BrianDH | last post by:
Hi I am using a SaveFileDialog with an RichTextBox. I am trying to save what is in the RTB as file type html. All I end up with is garbage. Dim saveFile1 As New SaveFileDialog...
1
by: berylwilson | last post by:
Hi all. In my application I use SaveFileDialog as follows. SaveFileDialog exportFileDialog = new SaveFileDialog(); exportFileDialog.Filter = "csv files (*.csv)|*.csv";...
2
by: ad | last post by:
Hi, I want to use saveFileDialog to save a file (like c:\aa.zip) to another place. How can I assgin c:\aa.zip to saveFileDialog
8
by: gopal | last post by:
Hi, I would like to display only the file names in SaveFileDialog control when i open it the Window in the without the complete file path Example if the file - -- test.doc is in folder...
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
3
by: Nayan | last post by:
Hi, I am trying to download a file from website, and to get the local file name form the user, I am using SaveFileDialog. I apply the filter (I parse the url to get the file name and assign)...
2
aestheticmind
by: aestheticmind | last post by:
Hello, How do you evaluate multiple values in a single Variable? Can someone give me a hand on how to set $filter so that it will evaluate all of the values. Right now it will only eval the first...
8
by: Joe Duchtel | last post by:
Hello - I have the following code to detemine a file name when my application is saving a file. The problem is that if the file already exists and I select the Yes button in the "Do you want to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.