473,545 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Common dialog control returns wrong filename !!

With the risk of being accused of multi-posting I would like to draw the
attention to a serious visual basic/windows issue discussed in the
microsoft.publi c.vb.bugs newsgroup. As pointed out below by Norman Diamond
the bug may result in loss of data when saving files with the standard
common dialog control.

Norman Diamond describes the problem as follows:

----------
In VB6 SP6, VB6 SP5, and possibly others, the common dialog box sometimes
returns a different filename from the name that is displayed on the filename
line.

Write a small program that opens a common dialog box for saving a file.
When executed, the dialog box shows a list of files presently existing in
the
directory. Do a single click on one filename and the filename is
automatically copied to the filename line in the dialog box. Edit the name
on the filename line to a nonexistent file, as if you want to save a new
file
with a slightly different name instead of overwriting the existing file.

Now, if you don't want to see the bug occur, then click immediately on the
Save button.

But if you do want to see the bug occur, for example if your customer
complains that your program overwrote their valuable data and you need to
prove whose fault it is, then you do the following instead. After slightly
editing the name in the filename line, click a blank spot inside the list of
filenames in the main part of the common dialog box. This wasted click does
not select a file. The name shown on the filename line remains as you
edited
it, it does not automatically change. Then click on the Save button. The
common dialog control returns to your program a filename of an existing file
instead of the new name that you put on the filename line. Your program
will
destroy your customer's existing data.

My boss just did similar tests with Microsoft Word, Excel, and other
applications. They do not have this bug. Only VB programs get hit by this
bug.
----------

I have not been able to find any solution/work-around to this problem.

Soeren
www.seqtools.dk
Jul 17 '05 #1
3 6777

"S.W. Rasmussen" <sw*@seqtools.d k> wrote in message
news:41******** *************@d read16.news.tel e.dk...
| With the risk of being accused of multi-posting I would like to draw
the
| attention to a serious visual basic/windows issue discussed in the
| microsoft.publi c.vb.bugs newsgroup. As pointed out below by Norman
Diamond
| the bug may result in loss of data when saving files with the standard
| common dialog control.
|
| Norman Diamond describes the problem as follows:
|
| ----------
| In VB6 SP6, VB6 SP5, and possibly others, the common dialog box
sometimes
| returns a different filename from the name that is displayed on the
filename
| line.
|
| Write a small program that opens a common dialog box for saving a
file.
| When executed, the dialog box shows a list of files presently existing
in
| the
| directory. Do a single click on one filename and the filename is
| automatically copied to the filename line in the dialog box. Edit the
name
| on the filename line to a nonexistent file, as if you want to save a
new
| file
| with a slightly different name instead of overwriting the existing
file.
|
| Now, if you don't want to see the bug occur, then click immediately on
the
| Save button.
|
| But if you do want to see the bug occur, for example if your customer
| complains that your program overwrote their valuable data and you need
to
| prove whose fault it is, then you do the following instead. After
slightly
| editing the name in the filename line, click a blank spot inside the
list of
| filenames in the main part of the common dialog box. This wasted
click does
| not select a file. The name shown on the filename line remains as you
| edited
| it, it does not automatically change. Then click on the Save button.
The
| common dialog control returns to your program a filename of an
existing file
| instead of the new name that you put on the filename line. Your
program
| will
| destroy your customer's existing data.
|
| My boss just did similar tests with Microsoft Word, Excel, and other
| applications. They do not have this bug. Only VB programs get hit by
this
| bug.
| ----------
|
| I have not been able to find any solution/work-around to this problem.
|
| Soeren
| www.seqtools.dk
|
|

I would think that setting the flag cdlOFNOverwrite Prompt, which brings
up a confirmation for any file overwrite, would suffice.

I reproduced this behavior, using VB6 SP4, with Common Dialog SP3. With
the flag set, it prompts for overwrite confirmation, showing the last
selected existing file name.
Jul 17 '05 #2

"Steve Gerrard" <my********@com cast.net> wrote in message
news:Np******** ************@co mcast.com...

"S.W. Rasmussen" <sw*@seqtools.d k> wrote in message
news:41******** *************@d read16.news.tel e.dk...
| With the risk of being accused of multi-posting I would like to draw
the
| attention to a serious visual basic/windows issue discussed in the
| microsoft.publi c.vb.bugs newsgroup. As pointed out below by Norman
Diamond
| the bug may result in loss of data when saving files with the standard
| common dialog control.
|
| Norman Diamond describes the problem as follows:
|
| ----------
| In VB6 SP6, VB6 SP5, and possibly others, the common dialog box
sometimes
| returns a different filename from the name that is displayed on the
filename
| line.
|
| Write a small program that opens a common dialog box for saving a
file.
| When executed, the dialog box shows a list of files presently existing
in
| the
| directory. Do a single click on one filename and the filename is
| automatically copied to the filename line in the dialog box. Edit the
name
| on the filename line to a nonexistent file, as if you want to save a
new
| file
| with a slightly different name instead of overwriting the existing
file.
|
| Now, if you don't want to see the bug occur, then click immediately on
the
| Save button.
|
| But if you do want to see the bug occur, for example if your customer
| complains that your program overwrote their valuable data and you need
to
| prove whose fault it is, then you do the following instead. After
slightly
| editing the name in the filename line, click a blank spot inside the
list of
| filenames in the main part of the common dialog box. This wasted
click does
| not select a file. The name shown on the filename line remains as you
| edited
| it, it does not automatically change. Then click on the Save button.
The
| common dialog control returns to your program a filename of an
existing file
| instead of the new name that you put on the filename line. Your
program
| will
| destroy your customer's existing data.
|
| My boss just did similar tests with Microsoft Word, Excel, and other
| applications. They do not have this bug. Only VB programs get hit by
this
| bug.
| ----------
|
| I have not been able to find any solution/work-around to this problem.
|
| Soeren
| www.seqtools.dk
|
|

I would think that setting the flag cdlOFNOverwrite Prompt, which brings
up a confirmation for any file overwrite, would suffice.

I reproduced this behavior, using VB6 SP4, with Common Dialog SP3. With
the flag set, it prompts for overwrite confirmation, showing the last
selected existing file name.


Even with the overwrite warning enabled it is highly misleading - and very
bad programming practice - to save the file with a title different from that
displayed in the title text field of the dialogbox. In my experience
warnings tend to be OK'ed without being read / understood... Especially in
this case where the content of the warning is quite unexpected to the user.

I am surprised that this bug has survived for such a long time - and that it
cannot be easily corrected having Steve McMahon's source code at hand:

http://www.vbaccelerator.com/home/VB...ct/article.asp

Soeren
www.seqtools.dk
Jul 17 '05 #3
You could always use the API control and set up a hook, and when the message
indicating a selection change was made, update the textbox to reflect that
name. IOW, if the user is silly enough to re-click the listview after
providing a custom filename, they lose their customization.

I suggest you get over looking for a 'fix' to this 'bug' ... it ain't going
to happen. This is a windows common dialog issue, not a VB issue.

--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
"S.W. Rasmussen" <sw*@seqtools.d k> wrote in message
news:41******** *************@d read16.news.tel e.dk...
:
: "Steve Gerrard" <my********@com cast.net> wrote in message
: news:Np******** ************@co mcast.com...
: >
: > "S.W. Rasmussen" <sw*@seqtools.d k> wrote in message
: > news:41******** *************@d read16.news.tel e.dk...
: > | With the risk of being accused of multi-posting I would like to draw
: > the
: > | attention to a serious visual basic/windows issue discussed in the
: > | microsoft.publi c.vb.bugs newsgroup. As pointed out below by Norman
: > Diamond
: > | the bug may result in loss of data when saving files with the standard
: > | common dialog control.
: > |
: > | Norman Diamond describes the problem as follows:
: > |
: > | ----------
: > | In VB6 SP6, VB6 SP5, and possibly others, the common dialog box
: > sometimes
: > | returns a different filename from the name that is displayed on the
: > filename
: > | line.
: > |
: > | Write a small program that opens a common dialog box for saving a
: > file.
: > | When executed, the dialog box shows a list of files presently existing
: > in
: > | the
: > | directory. Do a single click on one filename and the filename is
: > | automatically copied to the filename line in the dialog box. Edit the
: > name
: > | on the filename line to a nonexistent file, as if you want to save a
: > new
: > | file
: > | with a slightly different name instead of overwriting the existing
: > file.
: > |
: > | Now, if you don't want to see the bug occur, then click immediately on
: > the
: > | Save button.
: > |
: > | But if you do want to see the bug occur, for example if your customer
: > | complains that your program overwrote their valuable data and you need
: > to
: > | prove whose fault it is, then you do the following instead. After
: > slightly
: > | editing the name in the filename line, click a blank spot inside the
: > list of
: > | filenames in the main part of the common dialog box. This wasted
: > click does
: > | not select a file. The name shown on the filename line remains as you
: > | edited
: > | it, it does not automatically change. Then click on the Save button.
: > The
: > | common dialog control returns to your program a filename of an
: > existing file
: > | instead of the new name that you put on the filename line. Your
: > program
: > | will
: > | destroy your customer's existing data.
: > |
: > | My boss just did similar tests with Microsoft Word, Excel, and other
: > | applications. They do not have this bug. Only VB programs get hit by
: > this
: > | bug.
: > | ----------
: > |
: > | I have not been able to find any solution/work-around to this problem.
: > |
: > | Soeren
: > | www.seqtools.dk
: > |
: > |
: >
: > I would think that setting the flag cdlOFNOverwrite Prompt, which brings
: > up a confirmation for any file overwrite, would suffice.
: >
: > I reproduced this behavior, using VB6 SP4, with Common Dialog SP3. With
: > the flag set, it prompts for overwrite confirmation, showing the last
: > selected existing file name.
: >
: >
:
: Even with the overwrite warning enabled it is highly misleading - and very
: bad programming practice - to save the file with a title different from
that
: displayed in the title text field of the dialogbox. In my experience
: warnings tend to be OK'ed without being read / understood... Especially in
: this case where the content of the warning is quite unexpected to the
user.
:
: I am surprised that this bug has survived for such a long time - and that
it
: cannot be easily corrected having Steve McMahon's source code at hand:
:
:
http://www.vbaccelerator.com/home/VB...ct/article.asp
:
: Soeren
: www.seqtools.dk
:
:

Jul 17 '05 #4

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

Similar topics

5
6490
by: John Lauwers | last post by:
Hello, Is there a way to move the commondialog to a specific position ? Greets John
0
1945
by: Wanda | last post by:
Hello, I would like to create an interface which allow the user to select files from a ftp site using the common dialog contro. And after some manipulation in the program, the new output file will go to the same ftp site. My problem is firstly, when I select a file from the ftp site, its ..FileName of the common dialog control falls into...
1
3457
by: Dalan | last post by:
Before distributing a database that I have developed, I thought that I would ask the resident gurus a general question regarding Common Dialogs Control. Correct me if I'm wrong, but I have read somewhere that one can expect problems with different versions of Windows Common Dialogs. Is this true? I have used several in developing an Access...
1
3137
by: Dalan | last post by:
To avoid having potential conflicts and problems with different versions of Common Dialogs Controls, I have decided to change the ones I have used to API calls; however, this is somewhat new territory for me and would appreciate some assistance. One that I had been using is shown below and has worked fine. I have remarked most of the lines...
1
1672
by: Dalan | last post by:
Perhaps a couple of tips regarding API calls using a function module and I will be on my way to retiring the bug prone Common Dialogs Controls. One Common Dialog that I have been using is shown below and has worked fine. I'm have been using it to copy a few queries in HTML format to disk. So the main point is how to properly referenced an...
4
3666
by: Dorte | last post by:
Hi, I am using the code below to stream a CSV file with the response object. Dim FileName As String = "Test.csv" With Web.HttpContext.Current.Response Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" & FileName) .Charset = ""
6
1911
by: Steve Barnett | last post by:
I need to include a wizard in my application that will, as one of the steps, ask the user to select a file to open and (later) a file to save it as. The naff way to do this would be to have a button on the form that pops-up the common dialog. The cool way to do this would be to have the common dialog embedded in the wizard. I know it's...
1
2432
by: sirimanna | last post by:
I want to know how can i open some text file data using microsoft common dialog control.6 I know how to save text data using microsoft common dialog control.6 code are here, cdlfiles.filter="files(*.srt)\*.ami" cdlfiles.DefaultExt="str" cdlfiles.dialogTitle="save str notepad file" cdlfiles.DialogTitel=cdlOFNOverwritePrompt +...
3
2589
by: Koliber (js) | last post by:
sorry for my bad english when I fire up (from my c# code) a standard "file - save as " dialog, and when chosen location is a shered local network directory, where I do have rights to create and modify files, but I do not have rights to delete one, (and do save as with my filename) then this standard windows dialog seem to create...
0
7467
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
7401
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...
0
7656
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. ...
1
7419
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...
0
5971
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
5326
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
4944
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...
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
703
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.