Results 1 to 8 of 8

Thread: Binary Access Read Write Lock Read Write in vb.net?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    106

    Binary Access Read Write Lock Read Write in vb.net?

    Hello,
    I am looking for Binary File read Write Lock access in vb.net.

    In VB6 we can lock any file with the following code:
    Code:
    Open filename For Binary Access Read Write Lock Read Write As #1
    How to do same work with vb.net?


    Thanks !

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Binary Access Read Write Lock Read Write in vb.net?

    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Binary Access Read Write Lock Read Write in vb.net?

    The FileStream class allows you to read and write binary data from and to a file. Here's a link to the documentation for the class constructors, which provide all you need to specify how the file should be accessible:

    http://msdn.microsoft.com/en-us/libr...ilestream.aspx

    You can also call the File.Open method to create a FileStream, which may be slightly simpler options-wise:

    http://msdn.microsoft.com/en-us/libr...file.open.aspx

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Binary Access Read Write Lock Read Write in vb.net?

    Quote Originally Posted by opus View Post
    I cannot recommend strongly enough that you do not use that old VB6-style I/O in VB.NET. We're using VB.NET now so let's use it.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    106

    Re: Binary Access Read Write Lock Read Write in vb.net?

    Quote Originally Posted by opus View Post
    Code:
    FileOpen(1, "TESTFILE", OpenMode.Binary, OpenAccess.Read, _
       OpenShare.LockRead)
    Thanks alot.. that's working fine.

    Regards

  6. #6
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Binary Access Read Write Lock Read Write in vb.net?

    Quote Originally Posted by jmcilhinney View Post
    We're using VB.NET now so let's use it.

    WILCO, or in a more common language "I will Do as you told me!"
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  7. #7
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Re: Binary Access Read Write Lock Read Write in vb.net?

    Quote Originally Posted by green.pitch View Post
    Code:
    FileOpen(1, "TESTFILE", OpenMode.Binary, OpenAccess.Read, _
       OpenShare.LockRead)
    Thanks alot.. that's working fine.

    Regards
    Ehh....I would strongly recommend following jmc's advice and don't use that. That wouldn't play nice with other file handling operations in the Framework since they all use FileStreams in one way or another. FileOpen is nothing more than a carrot meant to lure VB6 developers into VB.Net.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  8. #8
    Junior Member
    Join Date
    Sep 2016
    Location
    Virginia Beach
    Posts
    18

    Re: Binary Access Read Write Lock Read Write in vb.net?

    Quote Originally Posted by Niya View Post
    Ehh....I would strongly recommend following jmc's advice and don't use that. That wouldn't play nice with other file handling operations in the Framework since they all use FileStreams in one way or another. FileOpen is nothing more than a carrot meant to lure VB6 developers into VB.Net.
    (I realize this is a very old thread)
    A carrot? Why do many .net users have to pee on everything VB6? I hate file streams unless I'm writing files as streams. And, the VB6 method more-closely mirrors what the OS has always provided.
    Faster, leaner, and doesn't require a massive .net runtime package. .net is cool and all, but don't beat up the tools that .net was built from!

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