ゴール
GUI のボタンを押して、リモート マシンから seclog.log ファイル (シマンテック AV ログ) を読み取り、ログの内容をアプリケーションのリッチ テキスト ボックスに表示したいと考えています。
機能するもの
ログファイルの読み取り以外のすべて
エラーメッセージ
System.IO.IOException was unhandled
Message=The process cannot access the file '\\HOSTNAME\C$\Program Files (x86)\Symantec\Symantec Endpoint Protection\seclog.log' because it is being used by another process.
Source=mscorlib
コード
//possible seclog paths
String seclogPath1 = @"\\\\" + target + "\\C$\\Program Files (x86)\\Symantec\\Symantec Endpoint Protection\\seclog.log";
String seclogPath2 = @"\\\\" + target + "\\C$\\Program Files\\Symantec\\Symantec Endpoint Protection\\seclog.log";
//if seclog exists
if (File.Exists(seclogPath1))
{
//output.AppendText("file exists at " + seclogPath1);
//var seclogContent = File.Open(seclogPath1, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Stream stream = File.OpenRead(seclogPath1);
StreamReader streamReader = new StreamReader(stream);
string str = streamReader.ReadToEnd();
output.AppendText(str);
streamReader.Close();
stream.Close();
}
私が試したこと
C# 別のプロセスで使用されているため、プロセスはファイル ''' にアクセスできません
問題をグーグルで調べる
複数の方法でファイルストリームを使用する