Vb. NET copies the instance code of all subdirectories and files under the entire directory

Source: Internet
Author: User
This article describes the copy of the entire directory of subdirectories and files of the code, the need for friends can refer to the copy code code as follows:


 public Sub copyderictory (ByVal directorysrc as DirectoryInfo, ByVal directorydes as DirectoryInfo)
&nbs p;       Dim Strdirectorydespath as String = Directorydes.fullname & "" & Directorysrc.name
        If not directory.exists (Strdirectorydespath) Then
            Directory.CreateDirectory ( Strdirectorydespath)
        end If
         Dim F, FS () as FileInfo
        fs = Directorysrc.getfiles ()
& nbsp;       for each F in FS
             file.copy (F.fullname, Strdirectorydespath & "" & F.name, True)
         Next
        Dim dirsrc, dirs () as DirecToryinfo
        dirs = directorysrc.getdirectories ()
       //recursively calls itself
        for each dirsrc in dirs
  & nbsp;         Dim Dirdes as New directoryinfo (Strdirectorydespath)
            copyderictory (DIRSRC, dirdes)
         Next
    end Sub
    Private Sub button1_click ( ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click
     & nbsp;  copyderictory (New DirectoryInfo ("C:documents and Settingsusernamefavorites"), New DirectoryInfo ("G:emp") )
    End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.