Results 1 to 2 of 2

Thread: [RESOLVED] file doesn't close?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    Resolved [RESOLVED] file doesn't close?

    i'm trying to make an updater for a program and i do this by checking the md5 of the file, but it seems that if i try to delete the file after getting the md5 i get an error saying its its being used by another process?


    Code:
                Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
                Dim f As FileStream = New FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
                f = New FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
                md5.ComputeHash(f)
    
                Dim hash As Byte() = md5.Hash
                Dim buff As StringBuilder = New StringBuilder
                Dim hashByte As Byte
    
                For Each hashByte In hash
                    buff.Append(String.Format("{0:x2}", hashByte))
                Next
    
                f.Close()

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    Re: file doesn't close?

    oops i just noticed i had this line:
    Code:
    f = New FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
    i removed it and it successfully closed now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width