Files are still locked after dispose/close
See original GitHub issueHi, 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:
- Created 5 years ago
- Comments:50 (39 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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).
I’ve just released NetVips 1.0.5 which bundle and depend upon libvips 8.7.