VB.NET Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



VB.NET Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
HTTP
IMAP
Encryption
MHT / HTML Email
PFX
RSA Encryption
S/MIME
Socket
Spider
Tar Archive
Upload
XML
XMP
Zip Compression
Misc

More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Byte Array
VB.NET FTPS
System.IO

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

Read Random-Access Disk File Seek Read-Only File Sharing

VB.NET source code showing how to open a disk file for random-access in read-only / share mode. Shows how to seek from file origin, current position, or end of file.

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

        ' Open an already-existing file for read-only.  Allow other
        ' processes to open the file while we have it open.
        Dim fs As New FileStream("test.dat", FileMode.Open, FileAccess.Read, FileShare.Read)

        ' Set the file pointer to 100 bytes from the beginning.
        fs.Seek(100, SeekOrigin.Begin)

        ' Set the file pointer to the end of file.
        ' There's no point in doing this when we open the file read-only.
        ' But if you are opening the file read-write, this may be something
        ' of interest.
        fs.Seek(0, SeekOrigin.End)

        ' Set the file pointer to 100 bytes beyond the current position.
        fs.Seek(100, SeekOrigin.Current)

        ' Set the file pointer to 100 bytes from the beginning.
        fs.Seek(100, SeekOrigin.Begin)

        ' Read 100 bytes at this position.
        Dim byteArray(100) As Byte
        Dim numBytesRead As Integer = fs.Read(byteArray, 0, 100)

        fs.Close()

    End Sub


 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.

Mail Component · XML Parser