如何在Windows的运行时中读取日志文件

问题描述:

当其他进程使用c#.net Windows应用程序编写同一日志文件时,如何在运行时读取日志文件而不锁定文件.

How can i read a log file in run time without locking the file, while other processes are writting the same log file, using c#.net windows application.

当我遇到这类文件/共享/锁定问题时,通常只需要复制一份文件,然后将其打开即可.但是,根据您正在执行的操作,可能对您不起作用.你试过什么了?我知道您可以指定是否打开文件以供只读...但是我不确定这是否可以解决您的锁定问题.您是否尝试过 File.OpenRead [ FileStream [
When I have these kinds of file/sharing/locking issues, I usually just make a copy of the file and open that one up instead. But depending upon what you are doing that might not work for you. What have you tried so far? I know that you can specify if you are opening a file for reading only...but I''m not sure if that would solve your locking problem. Have you tried File.OpenRead[^]? Or have you tried FileStream[^] with setting the mode/access/share parms to different settings to test it?