Pass variable in file path

Hi ,

I want to pass two variable [year1 and month1 ] in the file path .But when i provide the variable in the below formal
Directory.GetFiles(“C:\XXX\XXXXX\Desktop\C&P\FITVA+Year1+Month1\20_UP”,”ABC.xlsx”)

i am getting the error as could not find part of the path.

please help me to resolve this

1 Like

Hi,

Can you try the following?

Directory.GetFiles("C:\XXX\XXXXX\Desktop\C&P\FITVA"+year1+month1+"\20_UP","ABC.xlsx")

Regards,

HI ,
I tried but it dint work

Hi @rpatil

Can you share the complete path ?

Hi,

Are your variable string type?

If not, the following might work.

Directory.GetFiles("C:\XXX\XXXXX\Desktop\C&P\FITVA"+year1.toString+month1.toString+"\20_UP","ABC.xlsx")

If the above does not work, please check the following expression using Write Line activty if it’s same as your folder.

"C:\XXX\XXXXX\Desktop\C&P\FITVA"+year1.toString+month1.toString+"\20_UP"

Regards,

Hi @rpatil
Can i see the value of year1 and month1 esp the datatype of it. Thanks :smiley:

cheers :smiley:

Happy learning :smiley:

1 Like

HI,

Try this code and see…

Directory.GetFiles(“C:\XXX\XXXXX\Desktop\C&P\FITVA+Year1+Month1\20_UP”)

This will give you all the files inside the folder…

1 Like

Hi,

What is your Year1 and Month1 variable contains, is that variable is concatenated or each are sub folders?

Directory.GetFiles(“C:\XXX\XXXXX\Desktop\C&P\FITVA\" +Year1+Month1+"\20_UP”,”ABC.xlsx”)
try this in for each. if you still have doubt send your work flow

they are int32

1 Like

Can you convert it to string type and then concatenate it @rpatil

cheers :smiley:

Happy learning :smiley:

1 Like

Hi
Kindly write this in a writeline activity and let’s check what path is actually forming
“C:\XXX\XXXXX\Desktop\C&P\FITVA+Year1+Month1\20_UP”

Copy that output and paste in file explorer so that we can ensure that the folder path is correct

If not based on the output we can make changes

Cheers @rpatil

HI

Try with this
Directory.GetFiles(“C:\XXX\XXXXX\Desktop\C&P\FITVA"+Year1+Month1+"\20_UP”)
make sure Year1 and Month1 are string datatype if not then put (.ToString)

Hola, yo cuando necesito acceder a una ruta utilizo doble “\”
“C:\Users\xxxx\xx\xx\xxx\Template\Documento_Ejemplo.xlsx”
o en una actividad asignar genero el Sting completo de la ruta y luego solamente llamo a esta variable —> Directory.GetFiles(Ruta)