| When you pass long paths to CopyFile and XCopyFile, do not enclose them in double quotes. You can do this by passing the long file name to the function LongPathToQuote with the FALSE parameter. InstallShield is working on implementing an update to the CopyFile and XCopyFile function so that it will include support for long file names with double quotes for a future release.
The first section of the following example shows a section of code with double quotes that will fail. In the second section, LongPathToQuote is used in order for XCopyFile to succeed. //XCopyFile Fails and returns -2147024894
sLongPath="c:\\test\\test long path.txt"; LongPathToQuote(sLongPath, TRUE); MessageBox("LongPath with true: " + sLongPath, 0); //will display with quotes nReturn=XCopyFile(sLongPath, "c:\\test\\longpath", COMP_NORMAL); NumToStr(svString, nReturn); MessageBox("XCopyFile returned: " + svString, 0);
//XCopyFile succeeds and will return 0, indicating success
LongPathToQuote(sLongPath, FALSE); MessageBox("LongPath with false: " + sLongPath, 0); // without quotes nReturn=XCopyFile(sLongPath, "c:\\test\\shortpath", COMP_NORMAL); NumToStr(svString, nReturn); MessageBox("XCopyFile returned: " + svString, 0);
|