Cross-platform C# - System.io and other quirks
I'm writing a cross-platform code in C#. The code will involve IO, so I'm prolly using the System.io namespace.
However, I'd like to find out if it'll work with Linux, or any other OSes that C# support?
Commands like System.IO.Directory.CreateDirectory() , other than directory address, is there any other difference I need to take note of?
Also, what other parts in coding C# should I take note of when I'm plan for cross platform compatibility? (GUI, etc?)
I'm thinking of using Q开发者_开发问答T for GUI, is it refined for C# yet?
Thanks!
The primary difference is that you need to build your paths using Path.Combine instead of assuming that the paths are separated by backslashes (or forward slashes if you're coming from Nix). All of the System.Io libraries work great in Mono.
As to the UI, use GTK# - Qt doesn't really work for .NET (there are libraries, but GTK# is way more finished)
Run everything through MOMA after you have written it. It will identify for you any constructs that are not platform independent or not implemented in the Mono runtime.
Additionally compile both with MSBuild and the mono .net compiler.
Using Path.Combine and Environment.NewLine are a couple off the top of my head.
Avoid windows only construct (WMI and such) that have no linux/unix analogue.
However, I'd like to find out if it'll work with Linux, or any other OSes that C# support?
Microsoft's .NET stuff is Windows-specific.
If you want to produce something cross-platform in .NET, you want to be looking at the Mono documentation for guidance.
I think it should using the Mono Project In Unix based operating systems (Mac and Linux)
精彩评论