7网络 无法打开并写入文件_文件已在XXX打开,无法删除?

文件正在使用,无法删除?

常见的问题,冷门的解决方案

问题

当我们想要删除某个文件夹或文件时,冷不胜防地会出现以下类似的情况,一般只能不甘心地跳过,其实我们还是有办法来解决这个看似不是问题的问题

78c430399727c4b0da141574be3a88fd.png

解决方案

1)按Ctrl+Shift+Esc启动任务管理器

2)依次点击【性能】--【打开资源监视器】

3)点击【CPU】,在【关联的句柄】中搜索一开始删除文件时提示的【Adobe IPC Broker】,注意不一定要输入完整的搜索字眼,只要输入【Adobe】即可,避免过滤掉相关文件造成无法搜索到结果

02055cffdab72a8108f0982163fe4be2.png

48222ca80e1ece0588deca1511c3be47.png

e3112691413c68a49c65fc409fe74811.png

6ef8487824c8e7b1b8fd26ad21e65d9c.png

4)如上图,右键将相关的程序进程结束即可,注意【句柄名称】的路径,要找到与路径相对应的文件程序,避免结束与之无关的其他程序进程,下图是我们想要删除的文件

f690d90caad32529c342a2a3e7db171a.png

2cc4975e44a5b63deb0f8cce5b650772.png

5)确定无误后,结束进程。最后回到最初想要删除的文件位置重试

33fa5116c7f7d0168220f78caeaf6bd9.png

PS:该解决方案适用于那些不影响系统正常运行的文件,对于结束进程后会影响系统稳定性的文件,系统会自动禁止你的操作

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 以下是一个简单的实现,它将读取xxx.c文件的内容,删除多余的空白和空行,并将结果写入xxx_bak.c文件。 ```c #include <stdio.h> #include <ctype.h> int main() { FILE *input_file, *output_file; char c, last_c = '\0'; int inside_comment = 0, inside_string = 0; input_file = fopen("xxx.c", "r"); output_file = fopen("xxx_bak.c", "w"); while ((c = fgetc(input_file)) != EOF) { if (inside_comment) { if (last_c == '*' && c == '/') { inside_comment = 0; } } else if (inside_string) { if (last_c == '\\' && c == '\"') { // escaped quote, do nothing } else if (c == '\"') { inside_string = 0; } } else { if (c == '\"') { inside_string = 1; } else if (c == '/' && last_c == '/') { // single line comment, skip until end of line while ((c = fgetc(input_file)) != EOF && c != '\n'); } else if (c == '*' && last_c == '/') { // multi-line comment inside_comment = 1; } else if (isspace(c)) { if (last_c != '\n') { // remove extra whitespace continue; } } } fputc(c, output_file); last_c = c; } fclose(input_file); fclose(output_file); return 0; } ``` 注意:这个程序并不是完美的,因为它可能会删除某些需要保留的空格,例如结构体的空格。此外,它也没有处理预处理指令(宏定义等)。 ### 回答2: 编写C语言程序实现将一个C程序文件xxx.c的语句(不包含宏和字符串等)的多余空白和空行全部删除,并将处理后的内容存入另一个文件xxx_bak.c。可以按照以下步骤来实现: 1. 打开xxx.c文件xxx_bak.c文件,分别使用fopen函数打开,获取对应的文件指针。 2. 使用fgets函数逐行读取xxx.c的内容,将每一行的内容存储到一个字符数组,如line[]。 3. 对于每一行的内容,在遍历它的过程,检查每个字符,将连续的空白符(空格、制表符等)替换成一个空格,并跳过连续的换行符。 4. 如果这一行只包含空格和换行符,则跳过这一行。 5. 将处理后的每一行写入xxx_bak.c文件,使用fputs函数将line[]的内容写入xxx_bak.c。 6. 重复步骤2-5,直到读取完整个xxx.c文件。 7. 关闭xxx.c文件xxx_bak.c文件,使用fclose函数关闭文件指针。 8. 完成。 这样就可以编写一个C语言程序来实现将一个C程序文件xxx.c的语句(不包含宏和字符串等)的多余空白和空行全部删除,并将处理后的内容存入另一个文件xxx_bak.c。 ### 回答3: #include <stdio.h> void removeExtraSpacesAndLines(FILE *src, FILE *dest) { int c, lastChar; int isSpaceOrLine = 0; while ((c = fgetc(src)) != EOF) { if (c == ' ' || c == '\t') { if (!isSpaceOrLine) { fputc(' ', dest); isSpaceOrLine = 1; } } else if (c == '\n') { if (!isSpaceOrLine) { fputc(c, dest); isSpaceOrLine = 1; } } else { fputc(c, dest); isSpaceOrLine = 0; } lastChar = c; } // Remove trailing newline character if exists if (lastChar == '\n') { fseek(dest, -1, SEEK_CUR); ftruncate(fileno(dest), ftell(dest)); } } int main() { FILE *srcFile, *destFile; char srcFileName[] = "xxx.c"; char destFileName[] = "xxx_bak.c"; // Open source file for reading srcFile = fopen(srcFileName, "r"); if (srcFile == NULL) { printf("Failed to open %s\n", srcFileName); return 1; } // Open destination file for writing destFile = fopen(destFileName, "w"); if (destFile == NULL) { printf("Failed to open %s\n", destFileName); return 1; } // Remove extra spaces and lines removeExtraSpacesAndLines(srcFile, destFile); // Close files fclose(srcFile); fclose(destFile); printf("Successfully removed extra spaces and lines from %s\nSaved as %s\n", srcFileName, destFileName); return 0; }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值