alphaleonis / AlphaFS

AlphaFS is a .NET library providing more complete Win32 file system functionality to the .NET platform than the standard System.IO classes.
http://alphafs.alphaleonis.com/
MIT License
558 stars 99 forks source link

Errormessages in the wrong language #498

Open HugoRoss opened 5 years ago

HugoRoss commented 5 years ago

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