Q105860: PRB: CopyFile and XCopyFile Functions Do Not Handle Long Filenames With Double Quotes
Products
InstallShield 2009 Premier, InstallShield 2009 Professional
Project Type
InstallScript, InstallScript MSI
Symptoms

The CopyFile and XCopyFile functions do not handle long filenames with double quotes.


Cause

If you call LongPathToQuote on a long file name to put double quotes around the path before a call to either CopyFile or XCopyFile, it causes the functions to fail.


Resolution

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);


Additional Information

This issue is being tracked as a Feature Modification Request in work order #1-7A5FE.


Last Modified Date: 05-26-2009ID: Q105860