A directory separator divides directory and file names in a path. Windows uses a backslash (\), while Linux uses a forward slash (/). Hardcoded Windows paths can therefore fail after deployment to Linux. section 27.3.2
Build a portable path
Instead of writing "subdir\\myfile.json", construct the path with Path.Combine("subdir", "myfile.json"). This selects the appropriate separator for the platform, allowing the same application to load the file on Windows and Linux. section 27.3.2
When deploying across operating systems:
- Avoid hardcoding directory separators in application paths. section 27.3.2
- Use Path.Combine to create paths for the current platform. section 27.3.2
