I get the following exception:
D:\Try\folder\filename_1_06_09_2014_12:46:18.txt (The filename, directory name, or volume label syntax is incorrect)
While using timestamp in renaming filename here:
for (int i = 0; i < children.length; i++) {
String fileName = new SimpleDateFormat("MM_dd_yyyy_hh:mm:ss").format(new Date());
copyDirectory(new File(sourceLocation, children[i]), new File(targetLocation, files+"_"+fileName+".txt"));
}
I can't figure it out where I use invalid characters in windows filename. Any suggestions please?
You cannot use colons :
to create file in Windows. If you absolutely need the timestamp then you could try to add underscores for them as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With