Show current open file name in Window.Title

Opening a file is working as expected but I would like that file name (or even the entire path) to be displayed in the main window title bar.
I can’t find any info on how this is done but I think it would have to happen somewhere in the OpenDialog?? code as posted:

[code] Dim dlg As OpenDialog
Dim f As FolderItem
dlg = New OpenDialog
dlg.Filter = FileTypes1.All //Restrict file types

f = dlg.ShowModal

If f <> Nil Then

If f.Exists Then
  Dim dataInput As TextInputStream

  Try        
    dataInput = TextInputStream.Open(f)
    tempArray() = Split(dataInput.ReadAll,EndOfLine) //(Encodings.ASCII)
    dataInput.Close        
  Catch e As IOException
    MsgBox("Error accessing file.")
  End Try

End If

EvaluateImportedData

End If

WindowMain.Title = CurrentFileName // THIS IS WHERE IT NEEDS TO HAPPEN [/code]

Cheers.

...
End If
    WindowMain.Title = f.Name
    EvaluateImportedData
  End If

http://documentation.xojo.com/index.php/FolderItem.Name

[quote=313672:@Axel Schneider] ... End If WindowMain.Title = f.Name EvaluateImportedData End If

http://documentation.xojo.com/index.php/FolderItem.Name[/quote]

Wunderbar!! Thanks so much Axel - it works perfect. I didn’t see that in my search.

For the record, WindowMain.Title = f.NativePath displays the entire path including the filename.

Thanks :slight_smile:

The line above restrict nothing. Test for yourself: drop a file whose extension (type) is not in your list (in FileTypes1).

BTW: did you know about the xDevLibrary ?

[quote=313682:@Emile Schwarz]The line above restrict nothing. Test for yourself: drop a file whose extension (type) is not in your list (in FileTypes1).

BTW: did you know about the xDevLibrary ?[/quote]

Emile, the “line above” does work in that it ONLY allows for *.txt files to be shown as per my specs in FileTypes1.

Yes, I’ve seen the xDevLibrary and have downloaded one of Eugene Dakins e-books (the Canvas one). I usually prefer “physical” books - I tend to learn more that way.

Note that under Windows, it is better to use FolderItem.DisplayName.

I understand what you wrote.
No, it does not, always.

Drop a png, a jpg or a simple folder and watch what happens.

Now, I forgot the Windows status for these. But if you plan (one day) to compile for macOS, you will really be in trouble.