C#使用File.Creat创建文件再操作报The process cannot access the file because it is being used by another process

使用File.Create(“123.xml”);后,再进行文件删除时,报The Process cannot access the file because it is being used by another process的异常。解决方法如下:

File.Create(“123.xml”).Close();

因为如果不Close(),那么这个文件一直被创建进程占着,直到创建进程被关闭。

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐