Create and delete folders in C

Source: Internet
Author: User

In the previous blog, I wrote a process that could not be killed. Now I want to write another folder that cannot be deleted (the file is the same). The so-called "no" can be deleted, but "deleted" can be deleted, and then created again immediately. The Code is as follows:

# Include <stdio. h> # include <windows. h> # include <io. h> // For access () # define _ CRT_SECURE_NO_WARNINGS // eliminate compiler warnings, such as fopen being insecure // determine whether bool checkFileExist (const char * fileName) exists in the file or file directory) // case insensitive {if (access (fileName, 0) // parameter 0 indicates the existence of the check file {return false;} return true;} int main () {char * logFile = "D: \ Log"; while (1) {if (! CheckFileExist (logFile) // If the folder does not exist, re-create {CreateDirectory (logFile, NULL); // parameter: folder name, Security Attribute} Sleep (100 );} return 0 ;}

To delete this folder, you must end the process. If the process failed to kill the process by using the method described in the previous article, it is really difficult to delete the folder. First, delete the folder, and the process immediately recreates the folder. Second, the process is killed, and another process is immediately restored. Third, another process is killed, the process immediately restores another process. In this way, mutual calls are mutually protected, and the deletion cannot be deleted, and the kill cannot be killed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.