Skip to content

Documentation: Handling of problematic paths on Windows #120995

@jkotas

Description

@jkotas

Context: #120639 (comment)

The documentation for handling of problematic paths on Windows, such as paths that with trailing spaces, needs improvements.

  • There is https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/mitigation-path-normalization however it talks about .NET Framework and it is not clear which parts of it apply to .NET Core

  • The documentation for various System.IO APIs include snippets that are either applicable to Windows only or .NET Framework only. For example, https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.createdirectory says "Trailing spaces are removed from the end of the path parameter before creating the directory." that is applicable to Windows only.

  • The documentation should include best practices for writing code that handles these paths correctly.

    • FileInfo and DirectoryInfo do support the trailing spaces, File and Directory do not.
      • Handles these paths correctly: foreach (var ff in new DirectoryInfo(".").EnumerateFiles()) { using (var fs = fi..Open(FileMode.Open)) { ... } }
      • This is going to fail on these paths: foreach (var f in Directory.EnumerateFiles(".")) { using (var fs = File.Open(f, FileMode.Open)) { ... } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.IOdocumentationDocumentation bug or enhancement, does not impact product or test codeuntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions