Search code examples
c#macosmonopath-separator

Is paths interpretation on mono on mac different from the .net windows version?


I'm translating an app from .net on windows to mono on mac. I found an error that was happening, that I think related with how the backslash is interpreted on mono - mac.

Path.GetDirectoryName("Assembly\\file.dll")

On mono for mac that return an empty string, on .net windows that return "Assembly". Is that the normal behaviour? can I change the way path are interpreted with some kind of configuration, or I need to replace every backslash with forwardslash?


Solution

  • on mono you can use MONO_IOMAP environment variable to ignore differences like path ( windows is case insensitive, unix is case sensitive) and path separator ( '\' vs '/' )

    see http://www.mono-project.com/docs/advanced/iomap/

    the best long term solution anyway is to use methods like Path.Combine or Path.DirectorySeparator to fix these problems