Dim str1 As String
Dim str2 As String
Private Sub copy_Click()     '复制函数
    str1 = ExplorerList1.FileName '得到原文件的完整路径
End Sub
Private Sub del_Click()
    Dim str4 As String
    str1 = ExplorerList1.FileName
    Kill str4
    ExplorerList1.RefreshList True
    ExplorerTree1.RefreshTree True
End Sub
Private Sub ExplorerList1_FolderClick()
    ExplorerTree1.FolderClick (ExplorerList1.FileName)
End Sub
Private Sub ExplorerTree1_TreeDataChanged()
On Error Resume Next
    ExplorerList1.TreeDatas = ExplorerTree1.TreeDatas
End Sub
Private Sub Form_Load()
ExplorerTree1.InitialDir = "c:\windows\system"
End Sub
Private Sub Form_Resize()
    ExplorerTree1.Height = Me.ScaleHeight
    ExplorerList1.Height = Me.ScaleHeight
End Sub
Private Sub icon_Click()
    ExplorerList1.view = 0
End Sub
Private Sub list_Click()
    ExplorerList1.view = 2
End Sub
Private Sub New_Click()
    ExplorerList1.CreateDir
    ExplorerList1.RefreshList True
End SubPrivate Sub paste_Click()    '粘贴函数
    Dim str3 As Integer
    str3 = ExplorerTree1.Path    '拷贝到目标文件夹的路径
    FileCopy str1, str3
End Sub
Private Sub report_Click()
    ExplorerList1.view = 3
End Sub
Private Sub smallicon_Click()
    ExplorerList1.view = 1
End Sub我解决不了取得一个文件的文件名的问题,就像在c盘下的1.txt文件,我得到了
"c:\1.txt"的字符串,但是我还想要一个"1.txt"的字符串,应该怎么做呢?

解决方案 »

  1.   

    x = "c:\1.txt"
    MsgBox Mid(x, InStrRev(x, "\") + 1)
      

  2.   

    你可以写一个函数
    function GetShortName(StrPath as string ) as string
    for i =  len(trim(StrPath) ) to 1 setp -1
     if right(i,1) = "\" then
     endif 
    next i
    end function 
    思路大楷如此!自己完成
    好像有API函数也可以!!
      

  3.   

    楼上那个可能又问题(C:\test\test.txt)
      

  4.   

    你可先找到最右边的"\"位置,例如为:i
    那么你可以用 Right(str,i+1) 来取得文件名!注:原始路径和文件名称字符串 Str 应先去掉前导、后导空格才行!
      

  5.   

    x = "c:\1.txt"
    MsgBox Mid(x, InStrRev(x, "\") + 1)我好像有点不懂,如果我是C;\2\1.txt
    是不是也能得到同样的效果呢?
      

  6.   

    Str=Trim(Str)For i =  len(Str) to 1 setp -1
        If Mid(Str,i,1) = "\" then Exit For 
    next iIf i<>1 Then FileNameStr=Right(Str,i+1)
      

  7.   

    对于 "C;\2\1.txt" 的情况,可得出同样的结果:1.txt ,此时 i=5
      

  8.   

    更正:
    Str=Trim(Str)For i =  len(Str) to 1 setp -1
        If Mid(Str,i,1) = "\" then Exit For 
    next iIf i<>1 Then FileNameStr=Right(Str,i+1)      应改为:
                 FileNameStr=Right(Str,Len(Str)-i) 或者: 
                 FileNameStr=Mid(Str,i+1,Len(Str)) 
    才对!不好意思!