I have a process where I save attachment file of .pdf .xlsx .xls .csv , and I save the attachments with “save attachments” activity, then I “move file” to rename the saved attachment.
BUT, to move file with a new name I also hard code it as : director+“/”+newname+“.pdf”
I save it like this, but I dont want to hard code .pdf , I want it to be dynamic so I can save more than just a pdf. any suggestions?
Hi @jntrk
You can either use FileInfo methods to get extension of the file
Alternatively, a quick and dirty option is to substring after the last index of dot ( . ) Assign → fileExtension = filename.Substring(filename.lastIndexOf("." + 1)
Read the extension and in your move file, add that extension instead of the hard-coded “.pdf”
Hi @jntrk
My apologies, the correct syntax is Assign → fileExtension = filename.Substring(filename.lastIndexOf(".") + 1)
lastIndexOf(".") + 1 gives you string after the dot.
lastIndexOf(“.”) will yield you the extension including the dot e.g. “.pdf” or “.xlsx”
The +1 merely applies the substring one character later.