Listview? Search? and spcific lines in a text file?
What my question is,
Is it plausible to have a listview item search a specific folder that has nothing but text files in it, pull the first 2 lines from the text file(s) and display them in columns 1 and 2
if so, how would one go about doing it, i've been sitting here for a few hours, search google, msdn, and many of forums trying to get something, i've got absolutly nothing
(Given - Column 1 item, Text file line 1, and text file title will be 3 and the same)
thanx in adv to any and every
ps. i would completely understand if a timer is needed, was mainly going to use this during 'load' and/or after an update to the list of some sort
Smalls
Junior Poster in Training
70 posts since Mar 2008
Reputation Points: 12
Solved Threads: 2
ok, not quite sure i need all these imports!
but,
new objective(s)...
below is what i have so far
line 26
ListView1.Items.Add(New ListViewItem(New String() {SFile.Replace(".\Folder\", ""), CStr(FileLen(SFile))}))
doesn't do exactly what i would like it to do
i'm ok with the filename being in the first column as in the end, the filename, and the first line in the file will be the same(still working with '.txt' files)
what i would like is for the second column to be from the second line of the file
i believe that i could finish all of this if i could just figure out how to create, read, and write .txt files
read and write to specific lines
anyone have anything???
thnx n adv for any n all help
Imports System
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Public Class Main
Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Things completed on load
'Clear designer filled objects
NameLabel.Text = ""
DescriptionLabel.Text = ""
'Create working folder if it does not exist, then let the user know
If My.Computer.FileSystem.DirectoryExists(".\Folder") = True Then
Else
MessageBox.Show("Test Failed, Creating Directory!", "Directory Test!", MessageBoxButtons.OK, MessageBoxIcon.Warning)
My.Computer.FileSystem.CreateDirectory(".\Folder")
If My.Computer.FileSystem.DirectoryExists(".\Folder") = True Then
MessageBox.Show("Good to go! Directory Now Exists!", "Directory Test!", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If
'Gather a list of items in folder, then remove file path, then display items
Dim FilesInDir As String() = Directory.GetFiles(".\Folder", "*.txt", SearchOption.AllDirectories)
Dim SFile As String
ListView1.Items.Clear()
For Each SFile In FilesInDir
ListView1.Items.Add(New ListViewItem(New String() {SFile.Replace(".\Folder\", ""), CStr(FileLen(SFile))}))
Next
End Sub
Private Sub NewButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewButton.Click
'Windows form to add new entry
My.Forms.NewItem.Show()
End Sub
Private Sub EditButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditButton.Click
'Windows form to edit existing entries
End Sub
Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
'''I believe that this is the area that i need to fill'''
End Sub
End Class
Smalls
Junior Poster in Training
70 posts since Mar 2008
Reputation Points: 12
Solved Threads: 2
thnx 4 ur help
i got it finished yesterday mornning
Smalls
Junior Poster in Training
70 posts since Mar 2008
Reputation Points: 12
Solved Threads: 2