Move file using variables

Hello all,

Can anyone help me with the following? I am trying to use a For Each and a Move File to move files from one folder to another. I am also using Assign as the From Path & Destination Path in the Move File Activity will need to be a variable. I am getting a compiler error (see below). The variables I am using in the Assign activity’s are of type String Array and the argument type in the For Each is set to Object

The error I am getting is "Value of type ‘String’ cannot be converted to ‘1-dimensional array of String’

can you share the workflow

Sorry I can’t - The forum won’t allow me because I am a new user.

I can share more screen shots?

Yeas sure

TO get the files in that path, what are you using in the assign?

2 Likes

@BrianW

Try below expression to read files from folder.

  DirGetFiles [] = Directory.GetFiles("Folder path")

And then use ForEach loop to iterate one by one file and inside that use Move File activity to move the files.

     ForEach item in DirGetFiles
            - Use Move File activity

Source - item
Destination - Destination Folder Path

2 Likes

Hi @BrianW

Attached workflow to move all the files to desire folder

Move File.xaml (5.0 KB)

Regards,
JothyPrasanth M

Var_FolderPath (is a variable that has a folder path that changes each time I run the process).

transactionClientCode (is a code that changes each time I run the process)

Thanks for the reply - the problem is my folder path is stored in a variable becuase it will change each time I run the process. So I can’t use a hard-coded folder path

1 Like

@BrianW

That’s fine. Assign that path to one String variable and pass it there.

1 Like

Thanks for the reply @jothyprasanth.m but again my folder path is stored in a variable because it will change each time I run the process. That was my original question

Thanks @lakshman - can you explain further? Isn’t that what I am already doing?

1 Like

Use this below vb.net code to move your files in Invoke Code Activity,
My.Computer.FileSystem.MoveFile(“SourcePath”,“DestinationPath”).
DestinationPath Should have file name like xyz.xlsx.

@BrianW

Could you please print the below value using Message Box activity and show me screenshot once what it’s printing.

        DirGetFile
1 Like

DireGetFile is a path to a folder which contains files I want to move

“C:\Administration\Robotic Process Automation\07.Clients\Confirmations\2019-12-19\2019-12-19_FRG001_Confirmation”

@BrianW

Create one Array of String variable assign that folder path to that and it should be like this.

          getFiles [] = Directory.GetFiles(DirGetFile)

And then use ForEach loop as mentioned in my previous post.