Create directory before copying file
fix typo
Merge pull request #2854 from ma2gedev/patch-1

fix typo
should throw an exception when the second argument is negative