Backup Files in use by another Process

ε祈祈猫儿з 提交于 2019-12-11 06:28:09

问题


My application currently uses a third party API that has a bug forcing me to build it in 32bit. Unfortunately this conflicts with Window's Volume Shadow Copy as this apparently must be run in 64bit to work.

Are there any alternatives to VSS I can use to safely backup files that are currently being used by another process?


回答1:


Depending on your requiremen you can do something as simple as this:

FileStream fStream = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
StreamReader FileReader = new StreamReader(fStream, Encoding.UTF8);

This will work in some situtions, as it can read locked files. But i strongly recommend that you figure out your requirements first and post here.

IE are we talking about 2gb files that have data written to them in "random" locations? Or 2mb log files that are appended with new data every now and then?



来源:https://stackoverflow.com/questions/7159530/backup-files-in-use-by-another-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!