Unable to copy a file

Hello everyone,

I am trying to copy a file from the path below.

Str_Date + "" + Str_DownloadedFileName.ToString + “.*”

It seems like “.*” is not working. I got an error saying ‘Illegal characters in path.’

I put the wildcard at the end since the file extention is changeable.
Could you help me to resolve this?

Kind regards,

Can you please provide a sample file name that will come under that?

For example, if it’s a word file, it will come like
ID_Name.docx
then when it’s excel, it will come like
ID_Name.xls

when I set “.xls” in the end, it worked so I guess the proplem would be “.wildcard” part.
Do you have any idea why “.wildcard” does not work?

Thank you in advance.

Hi @9e389f79ff1549b677ac,

Try this assign (string of array)strfiles=directory.GetFiles(“folder_path”)
then in for each file in(string of array) strfiles you can copy that file to the destination folder where ever required

I hope this helps

Thank you for your tips but I am already using for each to get the file name and it feels like very complecated if I use “directory.GetFiles()”. It’d be very appreciated if you could help me to use wildcard.

Hi @9e389f79ff1549b677ac,

Try this
in If condition
Path.GetExtention(item) =“.xlsx” or Path.GetExtention(item) =“.docx”
then once you get the extension store that extension in the variable and pass it to copy file path where you using wild card option(you get the exact extension using this )
put anything in the file extension type and then copy that file

Hi @9e389f79ff1549b677ac
First Of all Get the file using Directory.Getfiles and the iterate it and Using the file index copy File. Refer the Below Workflow. I have used Select Folder To take Files Dynamically.
Thanks & RegardsCopyFilesDynamic.xaml (8.6 KB)

Hi

otherwise simply use dir method

dir(“D:\newFolder\Conf*”) like that

dir(Str_Date+ “” +Str_DownloadedFileName.ToString+“*”)