Closed
Description
Run the following code and ensure the application has access to the folder.
let dir_path = std::path::PathBuf::from(r#"C:\Users\testing.user\.bvm\bins\nodejs-node-8.12.0\node-v8.12.0-win-x64\node_modules\npm\test\npm_cache\_cacache\content-v2\sha512\32\c8\"#);
std::fs::create_dir_all(&dir_path).unwrap(); // ok
std::fs::write(&dir_path.join(r#"6992ba4671408a292bb3f2fae4cd10416dcedb6a214c169054af6bcc792b6ea56f7245333357cc59e4f84660380604b5ff338258ad46973218d864799b5e"#), "test").unwrap(); // error
Expected behaviour: It should create the file as I can create the file in file explorer and using other utilities like 7zip.
Actual behaviour: It errors with Os { code: 3, kind: NotFound, message: "The system cannot find the path specified." }
Meta
rustc +nightly --version --verbose
:
rustc 1.48.0-nightly (e2be5f568 2020-09-09)
binary: rustc
commit-hash: e2be5f568d1f60365b825530f5b5cb722460591b
commit-date: 2020-09-09
host: x86_64-pc-windows-msvc
release: 1.48.0-nightly
LLVM version: 11.0
Other Info
The following equivalent application works fine in C# on the same system:
var dirName = @"C:\Users\testing.user\.bvm\bins\nodejs-node-8.12.0\node-v8.12.0-win-x64\node_modules\npm\test\npm_cache\_cacache\content-v2\sha512\32\c8\";
Directory.CreateDirectory(dirName);
File.WriteAllText(Path.Join(dirName, "6992ba4671408a292bb3f2fae4cd10416dcedb6a214c169054af6bcc792b6ea56f7245333357cc59e4f84660380604b5ff338258ad46973218d864799b5e"), "test");
Edit: It occurs after the path length exceeds 260 characters.