
Note that I'd not like to use WinAPI calls. Is there any option to improve one of solution mentioned above or is there any other way to achieve my goal? This solution has the best potential but I can't make it override file content in any way - every method that writes file content appends instead of writing to beggining. First, download and install My Lockbox by going to the My Lockbox page on the FSPro Labs website and clicking the Download button. Third and last idea I came with is to open file in ab+ mode: fopen_s(&fp, file_path, "ab+") įread(buffer, sizeof(char), file_size, fp) įwrite("hello", 1, 5) // does not work - appends to end of file
Here, I could not find information whether freopen_s preserves file lock but I suppose that it does not. That's the second idea: fopen_s(&fp, file_path, "rb") This is the idea I came with: fopen_s(&fp, file_path, "rb") īut this solution generates small time window when file is not locked by process. By doing so, the file is unlocked, and you can delete it.I'd like to open file, read it's content and then fully override it.Īpart from that I'd like this file to be locked by process during whole procedure.
Right-click the filename and choose “Properties.”. In Process Explorer, look for the highlighted file name towards the bottom of the screen. Fill in the text box with the name of the locked file, then click the “Search” button to the right of the text field. Choose “Find Handle or DLL…” A search bar will appear. When asked, select “Yes” to minimize Process Explorer. Select “File” and choose “Show Details for All Processes.”. When asked, select “Agree.” This will launch the primary Process Explorer window. Launch “Process Explorer.” If your PC has a 64-bit CPU, double-click the “procexp64” item in the folder. If your system is equipped with a 32-bit CPU, double-click “procexp” instead. Choose “Extract all.” When you click it, a new window will appear.įrom here, the Process Explorer program will be installed, and the installation folder will open. Select the “Extract to” option on the top of the screen. Double-click it in the location folder to open the “ProcessExplorer.zip” folder. This will allow the Process Explorer ZIP archive to be downloaded to your PC. Click the “Download Process Explorer” button. Navigate to the Process Explorer webpage. Just double-click the file to move it to the “Running” section of the PC’s Task Manager. This policy must be enabled and related UAC settings configured.
For some users, this approach might be more convenient.
You can also use Windows Process Explorer to delete a locked file.