小编Tho*_*723的帖子

DeleteFile()不起作用

我正在尝试这个DeleteFile()功能,我在下面编写了这个程序.

#include <iostream>
#include <fstream>
#include <windows.h>
using namespace std;
int main(){
    FILE * filetxt;
    // creat a file
    filetxt = fopen("C:\\Users\\Thomas\\Desktop\\filetxt.txt", "w");

    // delete the file 
    if (DeleteFile("\\\\.\\C:\\Users\\Thomas\\Desktop\\filetxt.txt") != 0){
        cout<<"success";
    }else{
        cout<<"fail";
    }
    cin;
}
Run Code Online (Sandbox Code Playgroud)

但该计划没有按照预期的那样发挥作用.创建的文件未删除.

输出是:

fail
Run Code Online (Sandbox Code Playgroud)

c c++ winapi

1
推荐指数
1
解决办法
3546
查看次数

标签 统计

c ×1

c++ ×1

winapi ×1