My intention is for my application to run on windows and linux.
The application will be making use of a certain directory structure e.g.
appdir/
/images
/sounds
What would be a good way of handling the differences in file(path) naming differences between windows and linux? I don't want to code variables for each platform. e.g. pseudo code
if #Win32
string pathVar = ':c\somepath\somefile.ext';
else
string pathVar = '/somepath/somefile.ext';
You can use the Path.DirectorySeparatorChar
constant, which will be either \
or /
.
Alternatively, create paths using Path.Combine
, which will automatically insert the correct separator.
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