Dim attribute As System.IO.FileAttributes = IO.FileAccess.ReadWrite System.IO.File.SetAttributes(safold.SelectedPath, attribute) System.IO.File.Copy(safold.SelectedPath, ListBox1.Items.Item(0), True) MsgBox("Files copied")
Okay, im trying to copy a file to a folder (safold.selectedpath) and i keep getting a "Access to path [safold's path] denied" as you can see im even editing the files attributes to read and write and i still get this error, the selected path isnt read only either, so whats causing this problem?
Two possible causes I can think of. First, the path to copy the file to must contain the file name. It shouldn't be just a path to a folder to which you're copying. Second, if the file exists, File.Copy won't overwrite by default. To allow overwrite, you must call File.Copy(path_to, path_from, True).