Чтение файла если он занят другим процессом (The process cannot access the file because it is being used by another process.)
Как мне читать файл, чтобы не вылезала эта ошибка:
The process cannot access the file because it is being used by another process.
Суть в том, что файл уже занят другим процессом но мне все равно необходимо его читать.
using (StreamReader sr = File.OpenText(filePath))
{
string line = "";
while ((line = await sr.ReadLineAsync()) != null)
{
if (line.IndexOf("steamId=", StringComparison.Ordinal) <= 0 && line.IndexOf("steamid=", StringComparison.Ordinal) <= 0) continue;
string[] splitLine = line.Split('|');
string lineWrite = splitLine[1];
CustomSql.ExecuteQuery($"INSERT INTO `log_admin` (`action`) VALUES ('${lineWrite}')");
_lastVppLine = line;
}
}