Answer» Hello,
I WOULD like to know if anybody could tell me how to look for the following string in all, and I mean all the files in my computer. All that in Visual Basic.net of course.
String = 1591019361894212833234215551807
Thank You
AlmnCycle through each file and folder, opening them as a TEXT file. Scan through them looking for that string.
Odd question...Any hints on the code ?? The thing is I saved a document in many many places with different name on my computer, also the size is different because I made revisions afterwards. However all the files cointain this string: 1591019361894212833234215551807
Thank You
Al968Can't Google desktop search do that for you?well the point is that I would like a Visual Basic application that does that.
Al968get a list on all of the files in your computer us vb and then oppen eachfile in vb and have it look and see if a line contains what you are looking forDo you want to find a file or do you want to make a Visual Basic program? DECIDE which one is more important.
You can just use the ordinary Windows search to find certain text within a file.well actualy MAYBE your right I just want to do the Program
Al968I am just learning VB programming, so this is actually beyond my scope, but, I asked my instructor and she posted the following reply. I hope this puts you in the right direction.
Imports System.IO Imports System
Public Class Form1 Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New() MyBase.New()
'This call is required by the Windows Form Designer. InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub
'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents lbl As System.Windows.Forms.Label Friend WithEvents Label1 As System.Windows.Forms.Label Private Sub InitializeComponent() Me.lbl = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'lbl ' Me.lbl.Location = New System.Drawing.Point(96, 48) Me.lbl.Name = "lbl" Me.lbl.TabIndex = 0 Me.lbl.Text = "Search Word" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(224, 48) Me.TextBox1.Name = "TextBox1" Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(176, 136) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 2 Me.Button1.Text = "Search" ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(144, 88) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(144, 23) Me.Label1.TabIndex = 3 ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(416, 266) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.lbl) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim fileName As String = TextBox1.Text
Dim RDir As New DirectoryInfo("C:\")
Dim dir As DirectoryInfo Dim fi As FileInfo ''first we start with the subdirectories under the C drive For Each dir In RDir.GetDirectories ''the () tell us its a multidimensional string Dim strFile() As String = Directory.GetFiles("C:\" & dir.Name) 'Now we search through all the files in that directory For Each fileName In strFile
Label1.Text = System.IO.Path.GetFileName(fileName)
Next
Next
End Sub End Class
Hope this helps, Photowrench
Ok , I know how to look for for the string in the file but I don't know how to list all the files on my computer.
Any help appreciated
Al968At the simpliest you could just dump a list of file paths in a text file."At the simpliest you could just dump a list of file paths in a text file. " Does that list everyfile in the computer ? How do I do that ?
Thanks
Al968It's your program not mine! When you find a file that contains this string, the file path will presumably be contained within a variable. Just write this variable onto the end of a text document. I suggest you READ some tutorials on file management if you cannot do this.
|