Share this page

# remove

File Manipulation Functions

Deletes the specified file.

    int remove( const char *path);

path | The full path of the file to delete.

For remove details, refer to your C language documentation.

## Return Values

The function returns zero on success and -1 on failure. It also sets the global variable errno to indicate the specific error.

## Example

This example, for the Windows platform, creates a new directory, xyz, and a new file under the directory, short_lifespan.txt. It then deletes the new file with remove.

Copy code

        extern int errno;
        char filename[1024], command[1024];
        char new_dir[] = "C:\\xyz";
        // Create a directory under root called xyz and make it the current dir
        if (mkdir(new_dir)) {
            lr_output_message ("Create directory %s failed", new_dir);
            return -1;
        }
        else
            lr_output_message ("Created new directory %s", new_dir);
        // Create a new file in the new directory. The text is the output of a dir command on the new directory
        sprintf(filename, "%s\\%s", new_dir, "short_lifespan.txt");
        sprintf(command, "dir %s > %s /w", new_dir, filename );
        system(command);
        lr_output_message ("Created new file %s", filename);
        // Now delete the file
        if (remove(filename) == 0)
            lr_output_message ("Removed new file %s", filename);
        else
            lr_output_message ("Unable to remove %s error %d", filename, errno);

    Example: Output:
    Action.c(13): Created new directory C:\xyz
    Action.c(20): Created new file C:\xyz\short_lifespan.txt
    Action.c(24): Removed new file C:\xyz\short_lifespan.txt

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: