Is there any special character that cannot be a part of the path in Windows or Unix that I can use it as a separator?
All forward slashes ( / ) are converted into the standard Windows separator, the back slash ( \ ).
If you prefer to hard-code the directory separator character, you should use the forward slash ( / ) character. It is the only recognized directory separator character on Unix systems, as the output from the example shows, and is the AltDirectorySeparatorChar on Windows.
The path separator is a character commonly used by the operating system to separate individual paths in a list of paths.
Around 1970, Unix introduced the slash character ("/") as its directory separator.
what about the delimiter for PATH environment variable? ; for windows, and : for linux.
Wikipedia helpfully lists the reserved characters for different filesystems. Neither NTFS nor POSIX will accept the null or slash (/) characters in filenames. The slash character is obviously not a good separator, since it's common in POSIX paths, so maybe you could use null.
Of course null isn't suited to all situations (e.g. it isn't usually visible when printed), in which case you might have to use some sort of escaping scheme.
Java, which aims to work across different platforms, doesn't even try to find a common path separator. Instead each platform has its own character, accessible through an API.
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