Quantcast
Channel: Dan Byström's Bwain » .NET
Viewing all articles
Browse latest Browse all 10

The åäö Ghost Strikes… AGAIN!

$
0
0

Just when I thought we were out of the dark ages… something hit me right out of the blue.

During the summer something strange has happened, which I suspect happened because of some Microsoft security update. That is at least more probable than an ill-willing gnome in my machine fiddling with some bits. But you never know.

What has happened is that the

System.Windows.Forms.Application.ExecutablePath

property all of a sudden returns an incorrect result if the path contains a “non-ASCII” character like our swedish charaters åäö!!!

Replacing it with a

System.Reflection.Assembly.GetExecutingAssembly().Location

fixes the problem.

Demonstration:

  1. Fire up a new windows forms project and add “MessageBox.Show( Application.ExecutablePath );” to the default form’s constructor.
  2. Compile and place the exe in a folder called “c:\Our Application”.
  3. Run and you get “C:\Our Application\WindowsApplication1.exe”.
  4. Now rename the folder to “c:\Vår Applikation”.
  5. Run and you get “C:\V�r Applikation\WindowsApplication1.exe”. Where the “�” character is #65533.

The scary thing is that this behavior just changed over night.



Viewing all articles
Browse latest Browse all 10

Trending Articles