Rust Program to Remove an Existing File

Using this article, you can implement this Rust Program to Remove an Existing File here. We will start the discussion below to successfully implement this task.

Rust Program to Remove an Existing File

Rust Program to Remove an Existing File

// 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");
}
$ rustc main.rs

$ ./main
File samplet.txt is removed successfully

Final Words

I hope this article helps you to understand Rust Program to Remove an Existing File. If you encounter any issues let me know via the comment section.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment