错误描述:
The process cannot access the file because it is being used by another process
解决:将读取文件的方式改成 var stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)问题解决
文件访问权限设定
文件打开模式,选择添加方式:FileMode.Append
文件访问权限选择写权限:FileAccess.Write
文件共享方式:
FileShare.ReadWrite 不允许其它进程删除,对于唯一的主控方不允许其它人删除;
FileShare.Delete | FileShare.ReadWrite 辅助方允许其它进程删除。
FileStream fileStream = null;
fleStream = new FileStream(FileNamePattern, FileMode.Append, FileAccess.Write,FileShare.Delete | FileShare.ReadWrite);