The SaveAsDialog example DOES NOT WORKS on a genuine, unchanged OS properties (Windows 8.1); for your convenience, I pasted the example below:
[code]Dim dlg as New SaveAsDialog
Dim f as FolderItem
Dim txtType as New FileType
txtType.Name = “Text File (*.txt)”
txtType.MacType = “TEXT”
txtType.Extensions = “txt”
Dim htmlType As New FileType
htmlType.Name = “HTML File (*.htm, *.html)”
htmlType.MacType = "HTML "
htmlType.Extensions = “htm”
Dim csvType as New FileType
csvType.Name = “CSV File (*.csv)”
csvType.MacType = “TEXT”
csvType.Extensions = “csv”
Dim xlsType As New FileType
xlsType.Name = “Excel File (*.xls)”
xlsType.MacType = "XLS "
xlsType.Extensions = “xls”
dlg.InitialDirectory=SpecialFolder.Desktop
dlg.promptText=“Prompt Text”
dlg.SuggestedFileName=“Suggested Filename”
dlg.Title=“Title Property”
dlg.Filter=txtType + htmlType + csvType +xlsType
f=dlg.ShowModal()
If f <> Nil then
If Right(f.Name,3)=“txt” Then
MsgBox “1”
Elseif Right(f.Name,3)=“htm” Then
MsgBox “2”
Elseif Right(f.Name,3)=“csv” Then
MsgBox “3”
Elseif Right(f.Name,3)=“xls” Then
MsgBox “4”
End if
Else
//user canceled
End if[/code]
The example above is unchanged from the Language Reference.
BTW: if you check the code, you may say “It works !” and I will answer: "Yes, but it is because you changed ONE Windows important behaviour: the file extension property. That property is set to “Do not show” by default on every Windows version I used thru the time (down to Windows 2.12 I think).
f.ExtensionVisible is False (watch in the debugger) so right(f.Name,3) cannot be compared to a file extension !
On the debugger, you can see that f.DisplayName and f.Name does not have the file extension (all xxxPath does not displays the file extension too).
Type, MacCreator and MacType are useless here.
FolderItem.ExtensionVisible
I do not really understand if I can change this value TEMPORARY, for this blovk of code only (no if I correctly read the documentation).
At last, I am curious to know what happens on an OS X machine with file extension set to invisible (manufactory default settings): probably the same.
Nota: I know that I can change Windows File Extension visibility. BUT: the average Joe Newbie (is there’s one ?) do not. I met some people who set that flag to visible in their Windows machine, but do not know nor understand why !!!
In the mean time, I set manually .txt in the save as dialog and I was able to test the contents of the file I save (and it is good).