473,396 Members | 1,827 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,396 software developers and data experts.

How to insure file extension on new file.

HI,
I'm using saveFileDialog to get or make a file to save my stirngs to.

saveFileDialog1.Filter = "txt files (*.txt)|*.txt" ; //display dialog
saveFileDialog1.FilterIndex = 2 ;
saveFileDialog1.RestoreDirectory = true ;
DialogResult result2 = saveFileDialog1.ShowDialog();

This displays only txt files.
If the user selects an existing file all goes well.
The problem comes in when the user types in a file name and hits save. Then
the file that gets saved has no extension.
I have the AddExtension in properties set to true and the DefaultExt as txt.
Still no file extension.

What am I doing wrong?

TIA

Bill
Nov 17 '05 #1
1 1914
Ah yes,

Not only had to spell things out in code,
but had to clear the defaultExt field in props.

Thanks!

BTW:
Where can I find the FilterIndex options and what the numbers stand for?
They don't seem to make any difference with saveFIleDialog.
Have searched the C# site and NG's with no results.

Bill

"Otis Mukinfus" wrote:
On Fri, 15 Apr 2005 09:18:02 -0700, "BillZondlo"
<Bi********@discussions.microsoft.com> wrote:
HI,
I'm using saveFileDialog to get or make a file to save my stirngs to.

saveFileDialog1.Filter = "txt files (*.txt)|*.txt" ; //display dialog
saveFileDialog1.FilterIndex = 2 ;
saveFileDialog1.RestoreDirectory = true ;
DialogResult result2 = saveFileDialog1.ShowDialog();

This displays only txt files.
If the user selects an existing file all goes well.
The problem comes in when the user types in a file name and hits save. Then
the file that gets saved has no extension.
I have the AddExtension in properties set to true and the DefaultExt as txt.
Still no file extension.

What am I doing wrong?

TIA

Bill


This is an odd quirk of the OpenFileDialog and I suspect it's the same in the
SaveFileDialog. You must have CheckFileExists set to false or the AddExtension
property setting has no effect. In fact you cannot depend on the default
setting to work (the one in the properties). I found that you must set it in
code before it will work.
Otis Mukinfus
http://www.otismukinfus.com

Nov 17 '05 #2

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

Similar topics

4
by: Phester | last post by:
If a file has a .inc extension, or if it has a .inc.php extension, is it treated differently by the php interpreter? Or is it just a convention? I've been calling my included files filename.php...
6
by: Els | last post by:
If I use <? include "file.html"; ?> in the html of my document, do I _have_ to change the extension of that document to .php, or would it still work and be valid if I let it remain .html? --...
2
by: rsina | last post by:
Hi all, Could someone please compare and contrast the merits of using the commercial software insure++ to check for memory leaks in a C++ code with using the free software valgrind? I...
10
by: PengYu.UT | last post by:
Hi, Maybe this is an simple question. How can I insure that the objects of a class must be allocated in the heap? Thanks, Peng
3
by: Shapper | last post by:
Hello, I created a script to upload a file. To determine the file type I am using userPostedFile.ContentType. For example, for a png image I get "image/png". My questions are: 1. Where can...
1
by: Brian Henry | last post by:
Just thought maybe someone here would like to know this. It's an example code I just created quickly on how to figure out the name of a type of file based on its extension (say for example .DOC)...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
1
by: shahidrasul | last post by:
i want to download a file which user select from gridview, downloading is completing without problem but after download i want to refresh my page because i do some changes in db . but when...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...

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.