Rajesh’s Weblog

Just another WordPress.com weblog

Archive for the ‘Programming’ Category

Use FileStream to store and read file : VB.net

Posted by arajesh on April 9, 2008

Imports System
Imports System.IO

Public Class MainClass

Shared Sub Main()

Dim i As Integer
Dim theBytes(255) As Byte
For i = 0 To 255
theBytes(i) = CByte(i)
Next
Dim myFileStream As FileStream
Try
myFileStream = New FileStream(“test.txt”, FileMode.OpenOrCreate, FileAccess.Write)
myFileStream.Write(theBytes, 0, 256)
Finally
If Not (myFileStream Is Nothing) Then myFileStream.Close()
End Try

Dim theFile As FileStream
Try
theFile = New FileStream(“test.txt”,FileMode.Open, FileAccess.Read)
For i = 0 To (theFile.Length – 1)
Console.Write(theFile.ReadByte)
Next
Catch e As Exception
Throw e
Finally
If Not (theFile Is Nothing) Then theFile.Close()
End Try
End Sub

End Class

Posted in Programming | Leave a Comment »

Link – ASP Programming

Posted by arajesh on April 1, 2008

Posted in Links, Programming, Scripts | Leave a Comment »