Я намеренно создал файл с уловоем именем: < /p> [code]printf '\xC3\x28malformed_name.txt' | xargs touch < /code> Проверка его существует: < /p> ls ''$'\303''(malformed_name.txt' < /code> .net также может увидеть файл: < /p> open System.IO
Directory.EnumerateFiles "." |> Seq.toList // ["./�(malformed_name.txt"] < /code> Однако .net не может открыть файл!open System.IO
let path = Directory.EnumerateFiles(".") |> Seq.head
printfn "%s" path
let fileStream = File.OpenRead(path)
let reader = new StreamReader(fileStream)
let content = reader.ReadToEnd()
printfn "%s" content < /code> dotnet fsi scratch.fsx ./�(malformed_name.txt System.IO.FileNotFoundException: Could not find file '/demo/�(malformed_name.txt'. File name: '/demo/�(malformed_name.txt' at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException) at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize) at System.IO.File.OpenRead(String path) at .$FSI_0001.main@() in /demo/scratch.fsx:line 9 at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) Stopped due to error < /code> Как я могу взаимодействовать с файлами, которые могут иметь уродственные имена?dotnet --version 9.0.103 [/code] on linux (с меткой C# и F#, поскольку проблема показывает с обоими языками; я полагаю, это проблема стандартной библиотеки .NET)