开发者

Copy locked dbf file on windows using python

开发者 https://www.devze.com 2023-02-11 23:04 出处:网络
Well, almost everything is in title. I have a dbf file which I would like to copy even if it is lock开发者_运维问答ed (edited) by another program like DBU.

Well, almost everything is in title. I have a dbf file which I would like to copy even if it is lock开发者_运维问答ed (edited) by another program like DBU.

If I try to open it or copy with shutil.copy I get

>>> f = open('test.dbf', 'rb')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied: 'test.dbf'

I know that it is locked on windows level because I am unable to copy it witch batch or with windows explorer. But is there any method to copy such a file?


In general, you can't. Even if you were to circumvent the locking mechanism, another process might be in the middle of writing to the file, and the snapshot you would take may be in an inconsistent state.

Depending on your use case, Volume Shadow Copy might be of relevance.


There is a tool from Joakim Schicht that copies any locked file. The only issue is that some AV tag it as malicious, when it is not. Depending on your use case, this can be a solution.

https://github.com/jschicht/RawCopy

0

精彩评论

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