I am creating a program to look at the documents folder and copy the contents of that folder. I am getting folders that dont exist, that are hidden and have nothing in them. I had to put a Try/catch to make the program run.
As you can see from this picture.. My Music and My Videos isnt in the Documents Folder.
I have been trying to write code to not look at hidden files or exclude hidden files. no luck
I could write code to delete empty folders when i am done.
This is the code i am using. I tried to Modify it to help me but it doesnt work.. Please helpCode:Public Sub CopyFavoritesFolder(ByVal sourcePath As String, ByVal destinationPath As String) Dim sourceDirectoryInfo As New System.IO.DirectoryInfo(sourcePath) ' If the destination folder don't exist then create it If Not System.IO.Directory.Exists(destinationPath) Then System.IO.Directory.CreateDirectory(destinationPath) End If Dim fileSystemInfo As System.IO.FileSystemInfo For Each fileSystemInfo In sourceDirectoryInfo.GetFileSystemInfos Dim destinationFileName As String = System.IO.Path.Combine(destinationPath, fileSystemInfo.Name) ' Now check whether its a file or a folder and take action accordingly If TypeOf fileSystemInfo Is System.IO.FileInfo Then System.IO.File.Copy(fileSystemInfo.FullName, destinationFileName, True) Else ' Recursively call the mothod to copy all the neste folders CopyFavoritesFolder(fileSystemInfo.FullName, destinationFileName) End If Next




Reply With Quote
