我有一個C#應用程序試圖讀取另一個應用程序正在寫入的日誌文件。當我嘗試讀取文件時,出現IOException讀取已被另一個進程使用的文件
「進程無法訪問該文件...因爲它正在被其他進程使用 」。
我嘗試使用至今有以下幾種,但它們都沒有解決這個問題
var log = File.ReadAllText(logPath);
var stream = new FileStream(logPath, FileMode.Open);
using (var stream = File.Open(logPath, FileMode.Open))
{
}
http://stackoverflow.com/questions/3709104/how-do-you-read-a-file-which-is-in-use –
[stackoverflow.com/questions/4964588/open-file-readonly] (http://stackoverflow.com/questions/4964588/open-file-readonly) –