std::fs::remove_file - Rust
Description: API documentation for the Rust `remove_file` fn in crate `std`.
Keywords: rust, rustlang, rust-lang, remove_file

# 1.0.0[−][src]Function std::fs::remove_file

    pub fn remove_file<P: AsRef<Path>>(path: P) -> Result<()>

Removes a file from the filesystem.

Note that there is no guarantee that the file is immediately deleted (e.g., depending on platform, other open file descriptors may prevent immediate removal).

# Platform-specific behavior

This function currently corresponds to the `unlink` function on Unix and the `DeleteFile` function on Windows. Note that, this may change in the future.

# Errors

This function will return an error in the following situations, but is not limited to just these cases:

- `path` points to a directory.
- The user lacks permissions to remove the file.

# Examples

    use std::fs;

    fn main() -> std::io::Result<()> {
        fs::remove_file("a.txt")?;
        Ok(())
    }Run