如果想在文件资源管理器中显示一个文件,或者使用类似于OSX上的“Reveal in Finder”功能,那么在Rust中该如何实现呢?有没有可以帮助的crate呢?
fn main(){
reveal_file("tmp/my_file.jpg")
//would bring up the file in a File Explorer Window
}
我正在寻找类似于这个Python解决方案。
(翻译:我在寻找类似于这个Python解决方案的东西。)
use std::process::Command;
fn main( ) {
println!( "Opening" );
Command::new( "open" )
.arg( "." ) // <- Specify the directory you'd like to open.
.spawn( )
.unwrap( );
}
use std::process::Command;
fn main( ) {
println!( "Opening" );
Command::new( "explorer" )
.arg( "." ) // <- Specify the directory you'd like to open.
.spawn( )
.unwrap( );
}
补充说明:
根据@hellow的评论。
use std::process::Command;
fn main( ) {
println!( "Opening" );
Command::new( "xdg-open" )
.arg( "." ) // <- Specify the directory you'd like to open.
.spawn( )
.unwrap( );
}
[dependencies]
open = "3"
...并使用...打开某物...
open::that(".");
Windows
上执行此操作的说明(在重新阅读您的问题后,我认为这就是您想要的)。 - WBuckxdg-open
。 - hellow