Invisible folder

Joined
May 16, 2022
Messages
1
Reaction score
0
My QuickBackup program copies certain folders to an external drive
The following throws an error System.UnauthorizedAccessException: 'Access to the path 'C:\Users\myname\Documents\My Music' is denied.'

This is my code


Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'Copy contents to Documents & Date folder
Label1.Visible = True
Label1.Text = "Copying, please wait"
Refresh()
Dim mydatetime = DateTime.Now.ToString("dd-MMM-yyyy HH-mm-ss")
'make name for folder
Dim subFolder = pathToBackup & "Docs\" & "Documents " & mydatetime
MkDir(subFolder)
Label1.Text = subFolder
My.Computer.FileSystem.CopyDirectory("C:\Users\myname\Documents\", subFolder, True)
MsgBox("All done")
Label1.Visible = False
End Sub

Can someone help a beginner ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top