Share this page

# Example: remove

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.

        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 25.1-25.3 Function Reference 25.1-25.3 All View Local Help Center View Online Help Center Version: