I have a library that was created on Windows. In the library, I try to access a file that is marked in the project as content / copy if newer. For example:
string text = File.ReadAllText(@"projectpath\testfile.txt");
This works fine on windows; however, as soon as I run it on Linux, it fails - because it's expecting:
string text = File.ReadAllText(@"projectpath/testfile.txt");
How can I make this call agnostic of platform, or sensitive to it (so I can maybe put a #if
check in)?
Just use /
- it works fine on Windows and other platforms:
string text = File.ReadAllText(@"projectpath/testfile.txt");
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.