Cross Platform File Paths
·
170 words
·
1 minute read
Unlike with URLs which have a standardised format (they use forward-slashes to separate folders), file path separators will differ between operating systems. This is mainly a historic issue, as it’s almost inconceivable to change them at this stage. This means Windows uses back-slashes and *nix systems use forward slashes.
This is a pain however when writing cross platform software because if you know a file exists in a folder, and want to get it’s contents, you will have to use it’s folder name, a slash separator and the file name. We can tackle this problem in a number of ways. Here are two quick ones:
|
|