问题
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