Чтение файла (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 (isFind)
{
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;
}
if (_lastVppLine == "")
_lastVppLine = line;
if (_lastVppLine == line)
isFind = true;
}
}