std::fs::OpenOptions .open()工作正常,直到我下载了一个板条箱目录。我尝试过移除.toml依赖项和更改项目,但仍然收到使用OpenOptions的相同错误。使用std::fs::File .create() .open()似乎很好。
这是输出:Err(Os { code: 87, kind: InvalidInput, message: "The parameter is incorrect." })
用于在新项目中进行测试的确切代码。
fn main() {
let r = std::fs::OpenOptions::new()
.create_new(true)
.open("foo.txt");
println!("What is this bug: {:?}", r);
}锈蚀版1.59.0
发布于 2022-04-05 13:42:57
为了创建一个新文件,必须使用写或附加访问权限打开该文件。-- 新博士
这样做是可行的:
fn main() {
let r = std::fs::OpenOptions::new()
.create_new(true).write(true)
.open("foo.txt");
println!("What is this bug: {:?}", r);
}https://stackoverflow.com/questions/71726562
复制相似问题