Hello,
I need to count the number of objects in listbox1 that have an underscore "_" at the beginning of the file. The underscore will only ever be at the beginning of the filename.
Current Code:
Also what would be helpful is having a textbox that would replace the Underscore. As in whatever the user places in the textbook would be placed at the beginning of the file when it is copied. But I keep getting an error when I try to implement that feature.Code:Dim streamer As IO.StreamReader Dim directory1 = "C:\Server Media\Folder" Dim MediaLocation = "C:\Server Media\Folder\" Dim CopyFormat = "C:\Server Media\Folder\" + "_ " Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim files() As System.IO.FileInfo Dim dirinfo1 As New System.IO.DirectoryInfo(directory1) files = dirinfo1.GetFiles("*", IO.SearchOption.AllDirectories) For Each File In files ListBox1.Items.Add(File) Next Label2.Text = ListBox1.Items.Count End Sub
Code:Dim CopyFormat = "C:\Server Media\Folder\" + "_ " Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click For Each o As Object In ListBox1.SelectedItems My.Computer.FileSystem.CopyFile(MediaLocation & o.ToString, CopyFormat & o.ToString) Next ListBox1.Items.Clear() ListBox1.Refresh() Dim files() As System.IO.FileInfo Dim dirinfo1 As New System.IO.DirectoryInfo(directory1) files = dirinfo1.GetFiles("*", IO.SearchOption.AllDirectories) For Each File In files ListBox1.Items.Add(File) Next Label2.Text = ListBox1.Items.Count End Sub




Reply With Quote
