OnlineKnowledgeRepository
OnlineKnowledgeRepository
OnlineKnowledgeRepository
Would you like to react to this message? Create an account in a few clicks or log in to continue.


For Questions and Assistance please use the proper Category.. please..
 
HomeLatest imagesSearchRegisterLog in
Welcome guys!!.. In order for you guys to post your Questions and assistance requests,, please REGISTER first.. Only members can post.. If you have requests then feel free to email ADMIN neuron or SPAMMER onatzky.. thanks!
Search
 
 

Display results as :
 
Rechercher Advanced Search
Donation box
Latest topics
» Convert signed ZD to PD
Copy from 1 folder to another in VB.NET EmptyThu Sep 01, 2016 7:57 pm by neuron

» Abia State Polytechnic Admission form for 2013/2014 out!
Copy from 1 folder to another in VB.NET EmptyTue Oct 08, 2013 9:30 am by stevejoo

» Convert ZD to SIGNED PD
Copy from 1 folder to another in VB.NET EmptySun Sep 08, 2013 9:22 pm by neuron

» How to Speed Up My PC
Copy from 1 folder to another in VB.NET EmptyTue Feb 26, 2013 9:15 am by alphysudaria143

» Hi I'm alphysudaria143
Copy from 1 folder to another in VB.NET EmptySun Feb 17, 2013 12:25 am by alphysudaria143

» How to Copy all the Generations of a GDG
Copy from 1 folder to another in VB.NET EmptyThu Oct 11, 2012 8:30 am by neuron

» Remove Duplicates in a dataset though Sort
Copy from 1 folder to another in VB.NET EmptyThu Oct 11, 2012 8:23 am by neuron

» how to insert data into your access database vb.net
Copy from 1 folder to another in VB.NET EmptyTue Aug 14, 2012 9:56 am by neuron

» how to populate combobox in vb.net during form load
Copy from 1 folder to another in VB.NET EmptyTue Aug 14, 2012 9:53 am by neuron

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search
Help
Please support me my registering to NEOBUX
advertisements
Copy from 1 folder to another in VB.NET Banner3
Affiliates
free forum
 



 

 Copy from 1 folder to another in VB.NET

Go down 
AuthorMessage
neuron
Administrator
Administrator
neuron


Posts : 38
Join date : 2009-08-06

Copy from 1 folder to another in VB.NET Empty
PostSubject: Copy from 1 folder to another in VB.NET   Copy from 1 folder to another in VB.NET EmptyThu Aug 06, 2009 11:47 pm

Sample code to copy from one folder to another regardless of file location within the network..

Code:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If CopyDirectory("L:\XXXXX,TXT", "C:\XXXXX.TXT") Then
            MessageBox.Show("Copied successfully!!")
            End
        Else
            MessageBox.Show("Error copying directory")
        End If
    End Sub


Public Function CopyDirectory(ByVal Src As String, ByVal Dest As String, Optional _
  ByVal bQuiet As Boolean = False) As Boolean
        If Not Directory.Exists(Src) Then
            Throw New DirectoryNotFoundException("The directory " & Src & " does not exists")
        End If
        If Directory.Exists(Dest) AndAlso Not bQuiet Then
            If MessageBox.Show("directory " & Dest & " already exists." & vbCrLf & _
            "If you continue, any files with the same name will be overwritten", _
            "Continue?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, _
            MessageBoxDefaultButton.Button2) = DialogResult.Cancel Then Exit Function
        End If

        'add Directory Seperator Character (\) for the string concatenation shown later
        If Dest.Substring(Dest.Length - 1, 1) <> Path.DirectorySeparatorChar Then
            Dest += Path.DirectorySeparatorChar
        End If
        If Not Directory.Exists(Dest) Then Directory.CreateDirectory(Dest)
        Dim Files As String()
        Files = Directory.GetFileSystemEntries(Src)
        Dim element As String
        For Each element In Files
            If Directory.Exists(element) Then
                'if the current FileSystemEntry is a directory,
                'call this function recursively
                CopyDirectory(element, Dest & Path.GetFileName(element), True)
            Else
                'the current FileSystemEntry is a file so just copy it
                File.Copy(element, Dest & Path.GetFileName(element), True)
            End If
        Next
        Return True
    End Function


or you can try this one

Code:


        Dim appath As String
        Dim FileToCopy As String
        Dim NewCopy As String
        Dim DateString As String = Format(Now, "yyyy-MMM-d-hhmmss")

        appath = Application.StartupPath()

        FileToCopy = appath & "\SISdatabase.mdb"
        NewCopy = "C:\SISdatabase-" & DateString & ".mdb"

        If System.IO.File.Exists(FileToCopy) = True Then
            System.IO.File.Copy(FileToCopy, NewCopy)
            MsgBox("File Copied at " & NewCopy)
        End If
Back to top Go down
https://myonlinekr.forumotion.com
 
Copy from 1 folder to another in VB.NET
Back to top 
Page 1 of 1
 Similar topics
-
» How to know the content of a folder and get their attributes
» How to Check and create a folder in VB.NET
» How to Copy all the Generations of a GDG

Permissions in this forum:You cannot reply to topics in this forum
OnlineKnowledgeRepository :: All About PC :: Programming :: VB.NET-
Jump to: