今天使用File.Create("dddd.txt");后,打开这个文件时报The Process cannot access the file because it is being used by another process的异常。在网上找到解决方法如下:
File.Create("dddd").Close();
如果不Close(),那么这个文件一直被创建进程占着,直到创建进程被关闭。
本文介绍了一个常见的文件操作问题——在使用C#的File.Create方法创建文件后,若不关闭文件,将导致其他进程无法访问该文件,并引发异常。文中提供了一个简单的解决方法。
今天使用File.Create("dddd.txt");后,打开这个文件时报The Process cannot access the file because it is being used by another process的异常。在网上找到解决方法如下:
File.Create("dddd").Close();
如果不Close(),那么这个文件一直被创建进程占着,直到创建进程被关闭。
727
2万+

被折叠的 条评论
为什么被折叠?