如何解决用shfileooperation进行目录拷贝时不支持长文件名的问题,急!!!!!!!!!!!!!!!!!!(50分)

  • 主题发起人 主题发起人 redrain
  • 开始时间 开始时间
R

redrain

Unregistered / Unconfirmed
GUEST, unregistred user!
用winAPI shfileooperation可以实现目录级的文件拷贝,但拷贝的结果是长文件名被<br>自动截断,只支持8个字符的文件名。怎么解决这个问题?恳请诸位大侠速来相助!!<br><br>出来乍到,少送点钱,别嫌小气 ^_^
 
用CopyFile吧.
 
用findfirst 和 findNext 然后使用copyfile还不错,我用过了.
 
来自MSDN的消息:<br><br><br>PRB: File Names Truncated When Using SHFileOperation <br><br>Q186152<br><br><br>--------------------------------------------------------------------------------<br>The information in this article applies to:<br><br>Microsoft Win32 Software Development Kit (SDK), on platform(s):<br>Microsoft Windows 95 <br>The Microsoft Windows NT operating system <br>The Microsoft Windows 2000 operating system<br><br>--------------------------------------------------------------------------------<br><br><br>SYMPTOMS<br>When you use SHFileOperation to copy or move files, the destination file names are truncated to the 8.3 file name format. For example, the file name "New Document.temp" will be truncated to "NewDocum.tem". <br><br><br><br>CAUSE<br>The default behavior of SHFileOperation causes this problem. This behavior only occurs when you use a relative path for the destination. <br><br><br><br>RESOLUTION<br>Use a full path instead of a relative path for the destination. <br><br><br><br>STATUS<br>This behavior is by design. <br><br>Additional query words: <br><br>Keywords : kbLib kbOSWinNT400 kbOSWin2000 kbSDKWin32 kbOSWin95 kbGrpShell <br>Issue type : kbprb <br>Technology : kbOSWinNT kbOSWinSearch <br><br><br>Last Reviewed: October 21, 2000<br>&amp;copy; 2001 Microsoft Corporation. All rights reserved. Terms of Use.<br>&nbsp;<br><br><br><br>--------------------------------------------------------------------------------<br>Send feedback to MSDN.Look here for MSDN Online resources.
 
谢谢诸位!<br>如msdn所讲,用绝对路径是可以解决这个问题,但是这样的话,在程序打包时怎么办
 
用findfirst 和 findNext 然后使用copyfile还不错,我用过了.<br><br>我用的时候不行啊,程序如下,恳请del530指正:<br>&nbsp; &nbsp;if FindFirst('data/', faAnyFile, sr) = 0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; repeat<br>&nbsp; &nbsp; &nbsp; &nbsp; copyfile(pchar('data/'+sr.name),pchar('bakdata/'+sr.name),false);<br>&nbsp; &nbsp; &nbsp; until FindNext(sr) &lt;&gt; 0;<br>&nbsp; &nbsp; &nbsp; FindClose(sr);<br>&nbsp; &nbsp; end;<br>谢谢<br>
 
del530<br><br>我知道怎么回事了,不必麻烦了。谢谢
 
多人接受答案了。
 
后退
顶部