Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. File lock problem with Image.FromFile()

File lock problem with Image.FromFile()

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestiongraphics
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stefan Spenz
    wrote on last edited by
    #1

    Hi, when I load an image using this Bitmap bitmap = (Bitmap)Image.FromFile(pic.Path), it is not possible to delete the file afterwards, unless you exit the program. I tried to call .Dispose() on the object, but it seems like a bug in the FromFile method. I found out a workaround Bitmap origbmp = new Bitmap(pic.Path); Bitmap bitmap = new Bitmap(origbmp); origbmp.Dispose();. I keep working with the copy of the original bitmap as it's not locked anymore. But, loading an image using Bitmap's constructor, it's impossible to load animated GIFs as it seems that Bitmap doesn't support them. Now, how can I use animated GIFs and other image formats AND be able to delete the file afterwards? Thx :-D Stefan

    G 1 Reply Last reply
    0
    • S Stefan Spenz

      Hi, when I load an image using this Bitmap bitmap = (Bitmap)Image.FromFile(pic.Path), it is not possible to delete the file afterwards, unless you exit the program. I tried to call .Dispose() on the object, but it seems like a bug in the FromFile method. I found out a workaround Bitmap origbmp = new Bitmap(pic.Path); Bitmap bitmap = new Bitmap(origbmp); origbmp.Dispose();. I keep working with the copy of the original bitmap as it's not locked anymore. But, loading an image using Bitmap's constructor, it's impossible to load animated GIFs as it seems that Bitmap doesn't support them. Now, how can I use animated GIFs and other image formats AND be able to delete the file afterwards? Thx :-D Stefan

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Please don't cross post. --- b { font-weight: normal; }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups