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. C#
  4. Problem with blocked file access

Problem with blocked file access

Scheduled Pinned Locked Moved C#
questioncsharpcomcollaborationhelp
3 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.
  • W Offline
    W Offline
    Weckmann
    wrote on last edited by
    #1

    Hello all, I am using a foreign dll to read some data out of a certain file. The problem is: This dll somehow doesn't release the file once you open it to read the content with the dll. So after reading the data out of a file it is blocked for write-access until I completely close my whole application. My question is: How can I release these files? What I already tried: - setting all involved objects null - calling the GC manually - simply waiting some time hoping that .NET will release the file Nothing helped. Any ideas? Best regards, Bertram Weckmann Development Team G10 Software AG www.svizzer.com

    S 1 Reply Last reply
    0
    • W Weckmann

      Hello all, I am using a foreign dll to read some data out of a certain file. The problem is: This dll somehow doesn't release the file once you open it to read the content with the dll. So after reading the data out of a file it is blocked for write-access until I completely close my whole application. My question is: How can I release these files? What I already tried: - setting all involved objects null - calling the GC manually - simply waiting some time hoping that .NET will release the file Nothing helped. Any ideas? Best regards, Bertram Weckmann Development Team G10 Software AG www.svizzer.com

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Does code in the DLL that reads from the file call Dispose? If not, then you have no choice but to force garbage collection and finalization, with code like

      GC.Collect();
      GC.WaitForPendingFinalizers();
      GC.Collect();

      Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      W 1 Reply Last reply
      0
      • S S Senthil Kumar

        Does code in the DLL that reads from the file call Dispose? If not, then you have no choice but to force garbage collection and finalization, with code like

        GC.Collect();
        GC.WaitForPendingFinalizers();
        GC.Collect();

        Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        W Offline
        W Offline
        Weckmann
        wrote on last edited by
        #3

        Unfortunately I do not know what the DLL exactly does. But anyway, I already tried using the GC with no success. Even with the WaitForPendingFinalizers method. Even with the Marshal.ReleaseCOMObject method... Any other idea?

        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