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. Lock and Unlock

Lock and Unlock

Scheduled Pinned Locked Moved C#
helpcsharp
7 Posts 3 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.
  • V Offline
    V Offline
    Virendrak
    wrote on last edited by
    #1

    hi i lock a file.. and i acces this how i can unlock this file in c#.. plz send me any article, code, help for that problem.. Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...

    G 1 Reply Last reply
    0
    • V Virendrak

      hi i lock a file.. and i acces this how i can unlock this file in c#.. plz send me any article, code, help for that problem.. Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...

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

      What do you mean by locking the file? If you mean that you lock it as you open it, simply close it. --- b { font-weight: normal; }

      V 1 Reply Last reply
      0
      • G Guffa

        What do you mean by locking the file? If you mean that you lock it as you open it, simply close it. --- b { font-weight: normal; }

        V Offline
        V Offline
        Virendrak
        wrote on last edited by
        #3

        When I get the image from the file the file remains locked hi, Can you help? When I get the image from the file the file remains locked so the Delete fails with a "used by another process" how can i unlock this file...................? its urgent plz help and if any code and article send me on nicevirendra@rediffmail.com thanx Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...

        T G 2 Replies Last reply
        0
        • V Virendrak

          When I get the image from the file the file remains locked hi, Can you help? When I get the image from the file the file remains locked so the Delete fails with a "used by another process" how can i unlock this file...................? its urgent plz help and if any code and article send me on nicevirendra@rediffmail.com thanx Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...

          T Offline
          T Offline
          tarasn
          wrote on last edited by
          #4

          As I see the file stream remains open . You may copy the image into MemoryStream, then close FileStream .After this you will be able to delete the file and play with the image as you want. DevIntelligence.com - My blog for .Net Developers

          V 1 Reply Last reply
          0
          • T tarasn

            As I see the file stream remains open . You may copy the image into MemoryStream, then close FileStream .After this you will be able to delete the file and play with the image as you want. DevIntelligence.com - My blog for .Net Developers

            V Offline
            V Offline
            Virendrak
            wrote on last edited by
            #5

            Actually prob is that: i save an image... but when im update image... i want to delete old image frm my IMAGE folder... i use.. Image = Image.FromFile(imageFileName) : and thow the error : this is used by another procees help me out ..... thanx Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...

            T 1 Reply Last reply
            0
            • V Virendrak

              Actually prob is that: i save an image... but when im update image... i want to delete old image frm my IMAGE folder... i use.. Image = Image.FromFile(imageFileName) : and thow the error : this is used by another procees help me out ..... thanx Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...

              T Offline
              T Offline
              tarasn
              wrote on last edited by
              #6

              This code snippet reads image file, show it in PictureBox then delete image file from the disk. try { MemoryStream ms = null; FileInfo fi = new FileInfo(textBoxFilePathName.Text); byte [] buffer = new byte[fi.Length]; // read image file into stream using( FileStream stream = File.Open(fi.FullName, FileMode.Open) ) { stream.Read( buffer, 0, (int)fi.Length ); ms = new MemoryStream(buffer); } Image img = Image.FromStream(ms); // display image pictureBox1.Image = img; // delete image file File.Delete( textBoxFilePathName.Text ); //close stream ms.Close(); } catch (Exception e1) { MessageBox.Show( e1.Message ); } DevIntelligence.com - My blog for .Net Developers

              1 Reply Last reply
              0
              • V Virendrak

                When I get the image from the file the file remains locked hi, Can you help? When I get the image from the file the file remains locked so the Delete fails with a "used by another process" how can i unlock this file...................? its urgent plz help and if any code and article send me on nicevirendra@rediffmail.com thanx Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...

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

                If you load an image from a file, the file remains locked until you call Dispose on the image object. --- 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