![]() |
|
[VB.Net] Making a cool File/Directory Search - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework) +--- Thread: [VB.Net] Making a cool File/Directory Search (/Thread-VB-Net-Making-a-cool-File-Directory-Search) |
RE: [VB.Net] Making a cool File/Directory Search - jameswomack - 04-03-2013 How can I make a list that will actually provide you with a link to that file after searching for it? RE: [VB.Net] Making a cool File/Directory Search - ArkPhaze - 04-04-2013 (04-03-2013, 11:27 PM)jameswomack Wrote: How can I make a list that will actually provide you with a link to that file after searching for it? By link you mean string? As in filepath? List<T> generic class from the System.Collections namespace. Make the type string. RE: [VB.Net] Making a cool File/Directory Search - jameswomack - 04-04-2013 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. RE: [VB.Net] Making a cool File/Directory Search - ArkPhaze - 04-04-2013 (04-04-2013, 02:44 PM)jameswomack Wrote: 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. You're going to have to tell us what errors you are getting as nobody will be able to help until you do. You're doing something wrong, but until we know what errors you are dealing with you might as well ask us to grab a crystal ball and guess what your solution might be. The List<string> should be implemented to store the filepaths, then when a certain item is "clicked" grab the filepath from the list associated with the selection, and invoke the default handler for that filetype perhaps to open the file. RE: [VB.Net] Making a cool File/Directory Search - jameswomack - 04-04-2013 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, RE: [VB.Net] Making a cool File/Directory Search - Coder-san - 04-04-2013 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. RE: [VB.Net] Making a cool File/Directory Search - jameswomack - 04-04-2013 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"? RE: [VB.Net] Making a cool File/Directory Search - Coder-san - 04-04-2013 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. RE: [VB.Net] Making a cool File/Directory Search - jameswomack - 04-04-2013 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! RE: [VB.Net] Making a cool File/Directory Search - jameswomack - 04-05-2013 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. |