I am writing a game that needs to access a file. That is, it has to write to a file and read from it. The question is whether I can use the System.IO classes without having to worry about problems that might occur due to platform incompatibility. 
Do these methods work regardless of the platform that the game is running on? If not, is it possible to work with files independently from the platform?
Yes they work regardless of where you run it. Telling from my own experience, and have no idea why this could be otherwise.
Want to clarify this a bit. Of course you should use common sense when working with paths on different platforms. Usually you only work with relative paths in code, and when you work with absolute paths, you usually get them from your configuration or from another code (example: Path.GetTempPath()). Unless you hardcode your absolute paths and combine relative paths by hand (i.e. "mydir/myanotherdir") you should be fine. And even if you don't, mono has portability layer (read here - http://www.mono-project.com/docs/advanced/iomap/) to allow easy porting IO code from windows to linux. However don't rely on it and:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With