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(),那么这个文件一直被创建进程占着,直到创建进程被关闭。
所有评论(0)