如何在Windows的运行时中读取日志文件 [英] how can I read a log file in run time in windows

查看:72
本文介绍了如何在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?


这篇关于如何在Windows的运行时中读取日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆