Move file from one folder to another using invoke code - vb.net

I am trying to move a file from one folder to another. I would simply use the MoveFile activity if the file had the same name all the time - but not only does the process not drop the same file name all the time, i don’t want to limit the code and the process by designating a name for the file.

I tried the code below

    Dim sourcepath As String ="C:\PathA\FolderA\"
Dim endpath As String = "\\PathB\FolderB\"
File.Copy (sourcepath, endpath)
File.Delete(sourcepath	)

but i’m getting the following error - “Invoke code: Exception has been thrown by the target of an invocation”

Your assistance will be appreciated.

Thank you

Exactly because the end path looks weird to me. Why are you using an escape sequence in the beginning of a string?

Just use Move File activity.

The Destination Property of the Move File activity also supports a folder.

image

With that, you file name is preserved after it moved to the destination folder.

In the above example your final path will be: C:\Temp\MyFolder\MyFile.docx

Without the “” after MyFolder for the file destination ?

@Anjiba - could you please brief your query ?

My understanding is …you like to sweep one folder always and move the files from that folder to another folder if meets the condition right? If yes what is your condition?

I can help with the array.forach in the invoke code activity…which is just one one code…