question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Files are still locked after dispose/close

See original GitHub issue

Hi, I need to cleanup a file after having been “tumbnailed” with NetVips. But it seems that files are still locked depsite even outside the “using” blocks. Do I miss something ?

            using (var image = NetVips.Image.NewFromFile(fileClone))
            using (var thumb = image.ThumbnailImage(250)) {
                Console.WriteLine(thumb.Width);
                thumb.WriteToFile(string.Concat(fileClone, ".thumbnail.jpeg"));
            }

            File.Delete(fileClone);

If I comment the “thumb.WriteToFile” line, the file is no longer locked though and can be deleted. Seems to be related to WriteToFile.

I did try to explicitly call the “Close” method on both Image objects (in case it’s not done ine the Dipose). Still no luck…

Thanks for your attention !

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:50 (39 by maintainers)

github_iconTop GitHub Comments

1reaction
jcupittcommented, Jul 10, 2019

OK, merged to 8.8, this will be in 8.8.2. Thanks for pointing this dumbness out.

I had a quick look at reducev Kleis and coun’t see a useful place to add it. shrinkh could use it, but it wouldn’t make any difference (I think).

1reaction
kleisaukecommented, Sep 25, 2018

I’ve just released NetVips 1.0.5 which bundle and depend upon libvips 8.7.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - File remains locked after stream is closed
Make sure you are correct disposing the streams with using and try finally clauses. Also, you can use FileStream to set file access...
Read more >
Files remaining locked even after using program is closed.
4) Go back to the original program and export a new set of data to the same Windows Access database. The database is...
Read more >
kill - In windows, do file-locks stay after a process was ...
Yes, the locks remain but you cannot predict when they will get released by the OS. See LockFile() and LockFileEx(): If a process...
Read more >
[SOLVED] File locked by inactive user
Solution: Short answer is, this is a notoriously flaky part of Windows server file sharing that still depends on broadcasts.
Read more >
InDesign file won't unlock even after deleting the .idlk file
Solved: I have a book file with 2 documents in it open. One of those documents has a locked file. InDesign is spinning...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found