Jon Cage
Jon Cage

Reputation: 37500

How do I allow other applications to open a file I need to hold open?

I have a C++ windows application which opens a file (and keeps it open) as follows:

FILE* fp = NULL;
errno_t result = _wfopen_s(&fp, L"MyRawData.dat", L"wb");

This works fine but when I try and serve that file up via filezilla it denies access to the file when I try and download it (despite ticking the 'Allow downloading of files which are open for writing by another process' option).

Is this something I've done wrong in my software or a limitation of Filezilla / general windows issue?

Upvotes: 0

Views: 725

Answers (1)

msam
msam

Reputation: 4287

From the documentation of said function:

Files opened by fopen_s and _wfopen_s are not sharable. If you require that a file be sharable, use _fsopen, _wfsopen with the appropriate sharing mode constant (for example, _SH_DENYNO for read/write sharing).

Upvotes: 1

Related Questions