The use of hardcoded file separators causes portability problems.
Different operating systems use different characters as file separators. For example, Microsoft Windows systems use "\", while UNIX systems use "/". When applications have to run on different platforms, the use of hardcoded file separators can lead to incorrect execution of application logic and potentially a denial of service.
Example 1: The following code uses a hardcoded file separator to open a file:
...
FileStream f = File.Create(directoryName + "\\" + fileName);
...
[1] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 474