The source code to remove an existing file is given below. The given program is compiled and executed on UBUNTU 18.04 successfully.
// Rust program to remove an existing file
use std::fs;
fn main() {
fs::remove_file("sample.txt").expect("Unable to remove file");
println!("File samplet.txt is removed successfully");
}
Output:
$ rustc main.rs
$ ./main
File samplet.txt is removed successfully
Explanation:
Here, we removed the specified file "sample.txt" and printed the appropriate message.
Program/Source Code:
The source code to remove an existing file is given below. The given program is compiled and executed on UBUNTU 18.04 successfully.
Output:
Explanation:
Here, we removed the specified file "sample.txt" and printed the appropriate message.
need an explanation for this answer? contact us directly to get an explanation for this answer