• As G squared indicated, there is a UseDirectoryIfExists property you can set to True in the FileSystem Task. As to why your code isn't working - two things you might look into:

    1 - Variable Scope - can the task see it?

    2 - Is it designated ReadWrite on the script dialog?

    I clipped your code and ran it sucessfully, so there must be something in the setup.