Thirteen Years of Service
Posts: 7
Threads: 0
RE: [VB.Net] Making a cool File/Directory Search 04-03-2013, 11:27 PM
#21
How can I make a list that will actually provide you with a link to that file after searching for it?
•
Thirteen Years of Service
Posts: 7
Threads: 0
RE: [VB.Net] Making a cool File/Directory Search 04-04-2013, 02:44 PM
#23
I like the way the results are displayed using the original code on this thread, but I want users to be able to click on the results and navigate to them or open the file. I have tried implementing List of T and keep getting different errors.
•
Thirteen Years of Service
Posts: 7
Threads: 0
RE: [VB.Net] Making a cool File/Directory Search 04-04-2013, 03:36 PM
#25
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Dim strPath
strPath = "C:\QualWorld\ISO World\ISO9001\"
For Each Item As String In IO.Directory.GetFiles(strPath, "*" & ComboBox1.Text.ToString & "*" & ".*", IO.SearchOption.AllDirectories)
With ListView1.Items
'Strip the Filename from the Full file path
.Add(Item.Substring(Item.LastIndexOf("\") + 1), iconlist.Images.Count - 1)
.Add(IO.Path.GetFileNameWithoutExtension(Item))
'Add File size to second coloumn
.Item(.Count - 1).SubItems.Add(Math.Round(FileLen(Item) / 1048576, 2) & " MB")
'Add Full path to third coloumn
.Item(.Count - 1).SubItems.Add(Item)
'Show current Progress
Label1.Text = .Count.ToString & " Files found"
End With
Threading.Thread.Sleep(10)
Next
End Sub
Okay above is the code I got from this before I tried to add the links. This code works as it should. Can you please show me where to put in the List(of T)...Thanks,
•
Fourteen Years of Service
Posts: 2,622
Threads: 213
RE: [VB.Net] Making a cool File/Directory Search 04-04-2013, 03:47 PM
#26
Well if you read the comments in the code, one of them say "strip the filename from the full file path". So before or after it, add Item to the List you wish to use. This "Item" contains full file path.
![[Image: rytwG00.png]](http://i.imgur.com/rytwG00.png)
Redcat Revolution!
•
Thirteen Years of Service
Posts: 7
Threads: 0
RE: [VB.Net] Making a cool File/Directory Search 04-04-2013, 06:58 PM
#27
I guess I don't understand. I don't seem to be able to comprehend what you are suggesting. Can you send me an example? Does the current setup allow for links to be processed inside "listview1"?
•
Fourteen Years of Service
Posts: 2,622
Threads: 213
RE: [VB.Net] Making a cool File/Directory Search 04-04-2013, 07:04 PM
#28
Actually the full file path is already in the listview's third coloumn. So all you have to do is trigger the listview's item selected event and enter your code to open the file or whatever you want there.
If you are unable to follow this, then still you should find out on your own. Otherwise you'll have a hard time learning.
![[Image: rytwG00.png]](http://i.imgur.com/rytwG00.png)
Redcat Revolution!
•
Thirteen Years of Service
Posts: 7
Threads: 0
RE: [VB.Net] Making a cool File/Directory Search 04-04-2013, 11:00 PM
#29
Private Sub ListView1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDoubleClick
Dim OpenThis As String
Dim SelectedPath As Object
Dim PathConverted As Converter(Of Object, String)
SelectedPath = Me.ListView1.CheckedItems(Path.Text)
PathConverted = SelectedPath
OpenThis = "C:\" & SelectedPath
FileOpen(Access:=OpenAccess.Default, FileName:=OpenThis, FileNumber:=Nothing, Mode:=OpenMode.Append, RecordLength:=Nothing, Share:=Nothing)
End Sub
Above is my activation code and everything goes smooth until it reads the file name. I did notice that when it displays the path on my pc it leaves out the C:\ so I added it to the code and I still get the same error. "Bad file name or File Number." Any ideas???? Thanks again for all the help!
•
Thirteen Years of Service
Posts: 7
Threads: 0
RE: [VB.Net] Making a cool File/Directory Search 04-05-2013, 03:25 PM
#30
Dim OpenSelected As String
OpenSelected = "C:\" & TextBox1.Text.ToString
System.Diagnostics.Process.Start(OpenSelected)
Figured it out. I was trying to open the file all wrong. Above is the code I wound up using.
Coder-San - Thank you for tellg me that it triggering was a factor it all sort of fell into place after you said that.
•