用filecopy 复制文件的时候路径中有空格怎么处理?

xfpiao 2008-04-25 03:28:44
如题! 忘解答.
...全文
578 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
UltraBejing 2008-05-01
  • 打赏
  • 举报
回复
有问题请先GOOGLE,BAIDU
cbm6666 2008-04-27
  • 打赏
  • 举报
回复
'在VB之下直接使用
Private Sub Command1_Click()
FileCopy "C:\Program Files\testa b\cmd.txt", "c:\cmd.txt"
End Sub

'********************************
'shell(DOS命令)时要将长文件名改为短文件名
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Private Sub Command1_Click()
FileCopy Getshortname("C:\Program Files\testa b") & "\cmd.txt", "c:\cmd.txt"
End Sub

Public Function Getshortname(ByVal sLongFileName As String) As String
Dim lRetVal&, sShortPathName$, iLen%
sShortPathName = Space(255)
iLen = Len(sShortPathName)
lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen)
Getshortname = Left(sShortPathName, lRetVal)
jj = InStr(Getshortname, Chr(0))
If jj > 0 Then Getshortname = Mid(Getshortname, 1, jj - 1)
End Function

HtSoft 2008-04-27
  • 打赏
  • 举报
回复
带空格可以复制
比如下面这样的

FileCopy "d:\1 1 1\1.txt", "d:\2.txt"
lianxiangpanjin 2008-04-27
  • 打赏
  • 举报
回复
好像照样能复制过去
Sandrer 2008-04-25
  • 打赏
  • 举报
回复
用2楼的API函数或得该路径的DOS名称,再复制~
of123 2008-04-25
  • 打赏
  • 举报
回复
SourceFile = Chr(34) & SourceFile & Chr(34)
DestFile = Chr(34) & DestFile & Chr(34)
FileCopy SourceFile, DestFile
还想懒够 2008-04-25
  • 打赏
  • 举报
回复
Public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
ningyong58 2008-04-25
  • 打赏
  • 举报
回复
debug.Print asc(" ")
32
chr(32)代替空格
我碰到"号时,常用chr(34)解决。

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧