AlphaFS icon indicating copy to clipboard operation
AlphaFS copied to clipboard

Errormessages in the wrong language

Open HugoRoss opened this issue 6 years ago • 0 comments

The text of AlphaFS exceptions is returned in the OS language instead of the language of Thread.CurrentThread.CurrentUICulture:

Imports System.Globalization
Imports System.Threading
Imports System.Windows.Forms
Imports Alphaleonis.Win32.Filesystem
Imports SysIO = System.IO

Module Module1

    Sub Main()
        'On a German Windows...
        Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US")
        Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture
        Directory.CreateDirectory("C:\Temp") 'Ensure folder exists
        File.WriteAllText("C:\Temp\Foo.txt", "Some text...") 'Ensure file exists
        Try
            Directory.CreateDirectory("C:\Temp\Foo.txt")
        Catch ex As Exception
            Clipboard.SetText(ex.Message)
            MsgBox(ex.Message) 'Displays "(183) Eine Datei kann nicht erstellt werden, wenn sie bereits vorhanden ist: [C:\Temp\Foo.txt]"
        End Try
        Try
            SysIO.Directory.CreateDirectory("C:\Temp\Foo.txt")
        Catch ex As Exception
            Clipboard.SetText(ex.Message)
            MsgBox(ex.Message) 'Displays "Cannot create "C:\Temp\Foo.txt" because a file or directory with the same name already exists."
        End Try
    End Sub

End Module

HugoRoss avatar Oct 04 '18 11:10 HugoRoss