Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. HowTo copy entire folders with contents to a different folder?

HowTo copy entire folders with contents to a different folder?

Scheduled Pinned Locked Moved Visual Basic
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zaegra
    wrote on last edited by
    #1

    I am looking quite a while to find the source code for copying an entire folder + contents to a target folder. Can anyone help me? Because if i dont have that code, the program im working on can't be finished. Thanks, Zaegra :) --Zaegra--

    H 1 Reply Last reply
    0
    • Z Zaegra

      I am looking quite a while to find the source code for copying an entire folder + contents to a target folder. Can anyone help me? Because if i dont have that code, the program im working on can't be finished. Thanks, Zaegra :) --Zaegra--

      H Offline
      H Offline
      hannesHTG
      wrote on last edited by
      #2

      From MSDN (http://msdn.microsoft.com) The following example determines whether a specified directory exists, deletes it if it does, and creates it if it does not. This example then moves the directory, creates a file in the directory, and counts the files in the directory. [Visual Basic] Imports System Imports System.IO Public Class Test Public Shared Sub Main() 'Specify the directories you want to manipulate. Dim path As String = "c:\MyDir" Dim target As String = "c:\TestDir" Try ' Determine whethers the directory exists. If Directory.Exists(path) = False Then ' Create the directory. Directory.CreateDirectory(path) End If If Directory.Exists(target) Then ' Delete the target to ensure it is not there. Directory.Delete(target, True) End If ' Move the directory. Directory.Move(path, target) 'Create a file in the directory. File.CreateText(target + "\myfile.txt") 'Count the files in the target. Console.WriteLine("The number of files in {0} is {1}", _ target, Directory.GetFiles(target).Length) Catch e As Exception Console.WriteLine("The process failed: {0}", e.ToString()) End Try End Sub

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups