SSIS 2008: Illegal characters in path when trying to rename a file I have a task that should rename a file
I have a variable called RenameFileName
\\servername\csv\BACKUP\&quot; + (DT_WSTR,4)DATEPART(&quot;yyyy&quot;,GetDate()) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;mm&quot;,GetDate()) ,2) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;dd&quot;,GetDate()),2) + &quot;.csv

When I run the task I get the error
Illegal characters in path

Am I doing anything wrong? Below are a list of the variables I have tried
\\\\servername\\csv\\BACKUP\\&quot; + (DT_WSTR,4)DATEPART(&quot;yyyy&quot;,GetDate()) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;mm&quot;,GetDate()) ,2) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;dd&quot;,GetDate()),2) + &quot;.csv

\\servername\csv\BACKUP\&quot; + (DT_WSTR,4)DATEPART(&quot;yyyy&quot;,GetDate()) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;mm&quot;,GetDate()) ,2) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;dd&quot;,GetDate()),2) + &quot;.csv

&quot;\\servername\csv\BACKUP\&quot; + (DT_WSTR,4)DATEPART(&quot;yyyy&quot;,GetDate()) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;mm&quot;,GetDate()) ,2) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;dd&quot;,GetDate()),2) + &quot;.csv&quot;

&quot;\\\\servername\\csv\\BACKUP\\&quot; + (DT_WSTR,4)DATEPART(&quot;yyyy&quot;,GetDate()) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;mm&quot;,GetDate()) ,2) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;dd&quot;,GetDate()),2) + &quot;.csv&quot;

Please note that the following works:
\\\\servername\\csv\\BACKUP\\ABC.csv

This however does not work
\\\\servername\\csv\\BACKUP\\&quot;+1+&quot;.csv

It errors as soon a I put in double quotes. Single quotes are fine and they get put in the filename
Thanks
\\\\servername\\csv\\BACKUP\\&quot; + (DT_WSTR,4)DATEPART(&quot;yyyy&quot;,GetDate()) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;mm&quot;,GetDate()) ,2) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;dd&quot;,GetDate()),2) + &quot;.csv

You almost had it here but you missed the leading and trailing quotes.
\\servername\csv\BACKUP\&quot; + (DT_WSTR,4)DATEPART(&quot;yyyy&quot;,GetDate()) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;mm&quot;,GetDate()) ,2) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;dd&quot;,GetDate()),2) + &quot;.csv

Now you're missing the leading and trailing quotes and you failed to escape your back slashes.
&quot;\servername\csv\BACKUP&quot; + (DT_WSTR,4)DATEPART(&quot;yyyy&quot;,GetDate()) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;mm&quot;,GetDate()) ,2) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;dd&quot;,GetDate()),2) + &quot;.csv&quot;
Now you've got the quotes but not escaping the backslashes
&quot;\\servername\csv\BACKUP\&quot; + (DT_WSTR,4)DATEPART(&quot;yyyy&quot;,GetDate()) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;mm&quot;,GetDate()) ,2) + RIGHT(&quot;0&quot; + (DT_WSTR,2)DATEPART(&quot;dd&quot;,GetDate()),2) + &quot;.csv&quot;
This works correctly for me in SSIS expression.

FYI
\\servername\csv\BACKUP\&quot;+1+&quot;.csv
again you are missing the leading and trailing quotes.  However this won't work because it sees 1 as an integer and you need to convert it.
&quot;\\\\servername\\csv\\BACKUP\\&quot;+&quot;1&quot;+&quot;.csv&quot;

The above works.
Normally when doing these sorts of expressions I do it iteratively.  Adding 1 piece to the expression at a time so if it breaks I know where it broke.  Remember you can click &quot;evaluate expression&quot; to see the result.
If the expression evaluates correctly but the package doesn't work then it would be another issue with the package.