1 Attachment(s)
[RESOLVED] how to access the path location in listview
I would like to know, How I can access the path location in the listview? I have two column, named filename and location. I also able to search the filename in my directory and display the filename and its path location in the listview.
So I want to access the path location in the listview so that I can display the table. How to do that?
for example, I select the the list from listview and show the table.
How to remove the filename in the path location in the textbox? When the filename found. It show the full path location with the filename like this c:\project\data\block\blockc.shp .
Actually I just want to show the path location like this
c:\project\data\block\ . how to remove it?
Code:
Private Sub Insertsub(tempstr As String)
Dim i As Long
Dim sName() As String
Dim sPath As String
sName = Split(tempstr, "\") 'contains File name'
Dim lvItem As ListItem
Set lvItem = ListView1.ListItems.Add(, , sName(UBound(sName)))
lvItem.ListSubItems.Add , , "" & Left$(tempstr, InStr(1, tempstr, Chr$(0)) - 1)
Text2.Text = sName(UBound(sName)) ' show the data filename
Text3.Text = tempstr ' show the path location
End Sub
Code:
Private Sub Command1_Click() ' search button. When the file name found.It and display it in the listview
Dim tempstr As String, Ret As Long
tempstr = String(MAX_PATH, 0)
'returns 1 when successfull, 0 when failed
Ret = SearchTreeForFile("C:\Project\Data\", Text1.Text + ".shp", tempstr)
If Ret <> 0 Then Call Insertsub(tempstr)
ret2 = SearchTreeForFile("C:\Project\Data\", Text1.Text + ".img", tempstr)
If ret2 <> 0 Then Call Insertsub(tempstr)
If Ret = 0 And ret2 = 0 Then MsgBox "File not found"
End Sub
Re: how to access the path location in listview
Hmmm. Difficult read... but if I understand right;
Code:
Function PathOnly(ByVal path As String) As String
Dim s As String
s = Left(path, InStrRev(path, "\"))
PathOnly = s
End Function
MsgBox PathOnly("c:\project\data\block\blockc.shp") '-- returns: c:\project\data\block\