Ive a really stupid question to ask and I know I should know the answer
Any Idea??
Thanks,
Posted 22 November 2006 - 08:47 PM
Posted 23 November 2006 - 07:59 AM
'---seeking fs.Seek(11, SeekOrigin.Current) fs.Read(bytes, 0, 6) For i = 0 To 5 Console.Write(Chr(bytes(i))) Next fs.Close()
Posted 23 November 2006 - 08:37 AM
This post has been edited by phiban: 23 November 2006 - 11:24 AM
Posted 23 November 2006 - 06:01 PM
phiban, on Nov 23 2006, 09:37 AM, said:
Posted 23 November 2006 - 10:40 PM
Imports System.IO Public Class Form1 Inherits System.Windows.Forms.Form 'name of file to read from Const file_name = "C:\Documents and Settings\user\Desktop\tcp.txt" 'name of file to write to Const filename1 = "C:\Documents and Settings\user\Desktop\tcpCopy.txt" 'stream to read from Dim fs = New FileStream(file_name, FileMode.Open, FileAccess.Read) 'Stream to write to Dim fileStream As fileStream = New fileStream(filename1, FileMode.Create) 'Byte Array of size 80 Dim bytes(80) As Byte +Region " Windows Form Designer generated code " Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load calc() ReadByte() End Sub Private Sub ReadByte() 'Count is used to loop until all data has been collected Dim count As Integer 'Var incrementPos used to increment the position pointer in File i.e. After reading the first 80 bytes 'set the position to 80 and read the next 80 byte and so on Dim incrememtPos As Integer count = 0 Do Until count = calc() fs.Seek(incrememtPos, SeekOrigin.Current) fs.Read(bytes, 0, 80) For i As Integer = 0 To bytes.Length - 1 fileStream.WriteByte(bytes(i)) Next i bytes.Clear(bytes, 0, 80) count = count + 1 incrememtPos = incrememtPos + 80 Loop fileStream.Close() End Sub 'This Function preforms a calculation of a given file size and returns the size 'number and hence the number of passes needed to take all the data in from 'the txt file Public Function calc() As Integer Dim MySize As Long MySize = FileLen(file_name) Return MySize / 80 End Function End Class
tcp.txt (800bytes)
This post has been edited by mstester: 23 November 2006 - 10:46 PM
Posted 23 November 2006 - 11:08 PM
Posted 24 November 2006 - 11:01 AM
Posted 24 November 2006 - 11:40 AM