简体   繁体   中英

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 QT 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM