Copy file from to

Hello, I would like to copy an image file from the desktop to a folder … I have the complete path including the name of the file, both of the source and of the destination and I use the following code:

Var myFile As FolderItem = SpecialFolder.Resource(source)

If myFile.Exists Then
  Var destFile As FolderItem = SpecialFolder.Documents.Child(dest1)
  messagebox " fatto"
End If

where am I wrong?

… messagebox " OK IT EXIST"
messagebox " PROBLEM NOT EXIST"
End If

To try to figure out where the problem lies, I entered an IF condition, and it doesn’t find the source, even if it exists. Because ?

Try SpecialFolder.Resources.Child(source) for the source file.

If it’s on the desktop, use SpecialFolder.Desktop.child(“filename.ext”).

If source is a full path, don’t use it. Just the file name and extension. Same with destination.

The whole point of using SpecialFolder is so you don’t need to know the full path.

1 Like

I finally managed to copy the file with:

Dim CopiaDa as FolderItem
Dim A as FolderItem

I know the two full paths with the file name.

If one of the files is in your resources folder and someone moves the app, will your path still be correct?

No, no problem … the files are only on a PC and nobody moves them … I can delete or move them once the operations are done.