Copy a file : File Utilities « Stream File « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Stream File » File Utilities 
13.3.1.Copy a file
Imports System.IO
Imports System.Text

        
Public Class Tester
    Public Shared Sub Main
    

        Dim mySourceFileStream As FileStream
        Dim myDestFileStream As FileStream
        Dim bteRead() As Byte
        Dim intByte As Integer
        Dim bteMessage(128As Byte
        Dim strCopyMessage As String = ""

        Try
            myDestFileStream = New FileStream("dest.txt", FileMode.OpenOrCreate, FileAccess.Write)

            bteMessage = Encoding.ASCII.GetBytes(strCopyMessage)
            myDestFileStream.Write(bteMessage, 0, bteMessage.Length)

            mySourceFileStream = New FileStream("source.txt", FileMode.OpenOrCreate, FileAccess.Read)
            intByte = mySourceFileStream.Length
            ReDim bteRead(intByte)
            mySourceFileStream.Read(bteRead, 0, intByte)
            myDestFileStream.Write(bteRead, 0, intByte)

            myDestFileStream.Close()
            mySourceFileStream.Close()

        Catch ex As IOException
            Console.WriteLine(ex.Message)
        End Try
    End Sub
End Class
13.3.File Utilities
13.3.1.Copy a file
13.3.2.Use the HMACSHA1 hashing function to generate a checksum for a file.
13.3.3.Delete a file with kill
13.3.4.Delete a file
13.3.5.File copyFile copy
13.3.6.Move a File
13.3.7.Move a file with File.Move
13.3.8.Use FreeFile
13.3.9.Use FreeFile to read a text file
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.