0

i searched a bit but i cant find something useful.

i need to take my files to filestream (i can do this with file paths)
and i wanna save this files to somewhere else on my program. Is it possible that with the using FileStream?

THX for Replys ^^

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Oneryavuz
1

If you wanna move or copy files from one location to another using your program, there are easier ways than using FileStream.

Imports System.IO

    Private Sub FileCopy()
        Dim strFileSource As String = "C:\Temp\sourceFile.txt"
        Dim strFileDestination As String = "C:\Temp\destinationFile.txt"

        File.Copy(strFileSource, strFileDestination)
    End Sub

    Private Sub FileMove()
        Dim strFileSource As String = "C:\Temp\sourceFile.txt"
        Dim strFileDestination As String = "C:\Temp\destinationFile.txt"

        File.Move(strFileSource, strFileDestination)
    End Sub

    Private Sub CopyMoveMultipleFiles()
        Dim strSourceDirectory As String = "C:\Temp"
        Dim strDestinationDirectory As String = "C:\SecondaryTemp"
        Dim di As New DirectoryInfo(strSourceDirectory)

        'To copy files
        For Each fi As FileInfo In di.GetFiles
            fi.CopyTo(strDestinationDirectory & "\" & fi.Name)
        Next

        'To move files
        For Each fi As FileInfo In di.GetFiles
            fi.MoveTo(strDestinationDirectory & "\" & fi.Name)
        Next
    End Sub
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.