开发者

DotNetZip - create zip from accessed file

it is possible to use DotNetZip to create a zip from an accessed file (eg log file from another applicat开发者_StackOverflow中文版ion) ?

so create a zip when the log file gets written through the other application


Hmm, well, yes, if you are willing to write some code.

One way to do it is to compress the file AFTER it has been written and closed. You would need to have an app that runs with a filesystem watcher, and when it sees the log file being closed, it compresses that log file into a zip.

If you mean to imply, a distinct app that writes to a file and it automagically writes into a zip file, no I don't know of a simple way to do that. There is one possibility: if the 3rd party app accepts a System.IO.Stream in which to write the log entries. In that case, you can do that with DotNetZip. You can get a writeable stream from DotNetZip, into which the app writes content. It is compressed as it is written, and when the writing is complete, DotNetZip closes the zipfile. To use this, check the ZipFile.AddEntry() method that accepts a WriteDelegate. It's in the documentation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜