41625 - SaveAsDialog returns wrong name if InitialDirectory contains a folder with an extension

After many hours trying to find why I could not save correctly a file using SaveAsDialog, I’ve discovered that the reason was the folder where I wanted to save my file had a dot in its name.
I decided to file a case in Feedback and I discovered that it was already filed last year: #41625
It seems that the only work around is not using dots in the folder names, but obviously this is not a solution because I don’t decide how the users of my software name their folders.
The worst is that this bug doesn’t rise any exception but creates a chaotic name for the file in another folder that sometimes can overwrite another existing file.

Please solve this bug or give us a work around in the meantime.

The situation is actually worse than you think. Frequently Windows will add your domain to your username which immediately invalidates even basic functions like specialfolder.documents. That’s not even a user choice.

I actually filed one in February <https://xojo.com/issue/42774> and that shows that I was able to work around it by adding a dot at the end of the file name (at least for the Xojo IDE dialog for saving project files). Not sure if that workaround helps with your situation.

I just tried in 2015R4.1 and could not reproduce the error described in <https://xojo.com/issue/42774>.

It is specific to Windows - I assume that is what you tried it on (Windows 8.1 specifically in my case). Very interesting as they (Xojo) were able to verify the problem.

I wonder if the actions need to be called out in more detail. Typically I save project like this: “projectname.2016.4.1.xojo_binary_project” and so what I enter in the save as dialog is “projectname.2016.4.1” and what happens is the “.1” will get dropped off the end and I end up with “projectname.2016.4.xojo_binary_project”. So, if instead I enter “projectname.2016.4.1.” it will save as I intend it to.

Well. I tried under 8.1 and could not reproduce the issue either…

The problem is not how we save things. “We” can do it with any work around.
For me the BIG problem is the users.
I received a feedback from one of my main users. They are very upset because they can not save files in their folder structure.
And it seems it happens only with my application and I can not tell them: “You mustn’t use dots in you folder names”
Of course I could blame Xojo for this, but this is no the point.
What I need is a way to solve this problem, and the only way I see now is writing my on SavesAsDialog as I did many, many years ago, until I started to use the one offered by software: VB6, RalBasic and Xojo. It would mean going back and this is not the way.

It seems to be kind of random as well, as I was unable under Win 7 and Win 8.1 to observe the issue.

BTW there are two maybe related but different bugs :
In <https://xojo.com/issue/41625> mentioned by Ramon a subfolder with a dot becomes the only choice even if the user has selected something else.
In <https://xojo.com/issue/42774> linked to by Mark the name gets truncated after the last dot.


Check this code, please:

[code]Dim dlg as New SaveAsDialog
Dim f As FolderItem

Dim textType as New FileType
textType.Name = “fitxer text”
textType.Extensions = “.TXT”

dlg.InitialDirectory = SpecialFolder.Desktop
dlg.Filter = textType
dlg.SuggestedFileName = “test”

f = dlg.ShowModal()

MsgBox f.NativePath

Create a folder on your desktop called “Folder2.0”
If you try to save a file called “test.txt” in this folder it works ok.
If you try to save a file called “test” (with no extension) in this folder what I get is a file called always “folder2.txt” in my Desktop, no matter the name you try to save.

Which version ? 2016R1 ?

Alright. I confirm indeed that entering a file name without extension, .TXT will be added.

BUT, Ramon, at the risk of disappointing you, I do not believe that is a bug. Windows has the folder option “Hide extension for known file types”, so users can be shielded from extensions.

In that perspective, when the user enters “test”, the system appends automatically .txt which defines a text file and insures the said document is opened by the proper program.

You can see exactly the same behavior in other Windows programs, for instance Wordpad. If you chose “Save as” and enter “test”, it will automatically add “.txt”.

Unlike OS X, Windows does not have any other way to know the type of file than the extension. So saving a file without extension would break its type.

If you absolutely want the possibility to save without extension, then comment out textType.Extensions = ".TXT" . But you will probably get angry support requests when users double clicking on their extensionless documents will get the message : “choose the program you want to use to open this file” with a choice that probably does not show your app.

But I never saw what you report in 41625 that the name of the file ended to be Folder2.txt

Thanks Michel for the time you’ve devoted to this.
But I know perfectly what you say about files with no extension and how to use “hide extensions” on Windows.

Probably I did not explain the problem well:

  1. when I try to save “test” with no extension, what I want is that Windows adds .txt at the end of the name file, as it has been up to now (at least for me). That’s why I have added “dlg.Filter = textType” and it works…

  2. but this doesn’t happen when the folder you save the files in has a dot in its name. When this happens .txt is added, but not at the end of the name proposed but at the end of the name of the folder, cutting what it is at the end of the rightmost dot (if there is more than one dot): Instead of saving a file called “test,txt” at the folder “Desktop/Folder2.0”, what I get is a file called “Folder2.txt” at the folder “Desktop”.
    If you save inadvertently different files with different names in this folder, every time the new file overwrites the old one, because the name of the files is always: “Folder2.txt”

  3. At this moment I’m working with Windows 10 and 2016r1, but this is not relevant because the client who made me know the problem uses different computers with different Windows. Besides, I did not started case #41625. So, some other people has seen this bug and the case has been verified by Xojo people.

But if you say that you can not reproduce this bug, then I’m totally astonished and I don’t know what to say, except that Xojo people verified this bug.

Thanks again, Michel.

The problem had been reproduced, the cause narrowed down, and is scheduled to be fixed in a future release.

Sorry, Ramon. I wish I had been able to reproduce the error, but really what counts is that Joe was able to. And is going to fix it.

Thank you Joe.
This is very good news.
I will send you as much as possible new information if I get something relevant.

Thanks a lot, Michel. Seeing that this doesn’t happen in any context is also important.

Can you tell us the Feedback case#, so we can move it to the top of our priorities?

John, the case# is at the title of this conversation. Thanks.

Duh! Thanks -

I’ve just received this email:

[quote]Summary: SaveAsDialog returns wrong name if InitialDirectory contains a folder with an extension
Link: <https://xojo.com/issue/41625>

User “William Yu” has updated case #41625.

The following comments were left:

»»Status changed from ‘Verified’ to ‘Fixed’.
»»Report closed. Rank: 31st (97th percentile)

This case has been fixed and is waiting verification from our testing staff.[/quote]

I imagine i will take some time to be included in a release, but anyway: THANKS A LOT!