See if this helps.
1 ListBox, 1 Button
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim fbd As New FolderBrowserDialog
If fbd.ShowDialog = Windows.Forms.DialogResult.OK Then
With ListBox1.Items
.Clear()
getDirectoryList(fbd.SelectedPath, ListBox1)
MsgBox("Found.Directory(ies).Count: " & .Count)
End With
End If
End Sub
Private Sub getDirectoryList(ByVal selCoolFolderPath As String, ByRef selCoolListBox As ListBox)
For Each foundDirectory In Directory.GetDirectories(selCoolFolderPath)
With ListBox1
.Items.Add("file.count: (" & IO.Directory.GetFiles(foundDirectory, "*.*").Length & ") file.path: " & foundDirectory)
.SelectedIndex = .Items.Count - 1
End With
getDirectoryList(foundDirectory, selCoolListBox)
Next
End Sub
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
>>thanks codeorder, i'll try it now.
:)
>>I'd rather be fishing.
I'd rather be skating. xD
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
Dim myCoolFile As String = "C:\test.txt" '// your original file.
Dim myRenamedCoolFile As String = "testRenamed.txt" '// only your new file name and extension. file extension can be changed.
If IO.File.Exists(myCoolFile) Then
My.Computer.FileSystem.RenameFile(myCoolFile, myRenamedCoolFile)
MsgBox("File Renamed.", MsgBoxStyle.Information)
Else
MsgBox("File Does Not Exist.", MsgBoxStyle.Critical)
End If
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
>>...I can't implement it based on the above condition:
;)
Imports System.IO
Public Class Form1
Private arTemp() As String, iT As Integer
Private myCoolFileExtension As String = "*.tif"
Private myCool16File As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\withbar.txt"
Private myOtherFile As String
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim fbd As New FolderBrowserDialog
If fbd.ShowDialog = Windows.Forms.DialogResult.OK Then
getDirectoryList(fbd.SelectedPath, ListBox1)
MsgBox("(:.done.:)")
End If
End Sub
Private Sub getDirectoryList(ByVal selCoolFolderPath As String, ByRef selCoolListBox As ListBox)
For Each foundDirectory In Directory.GetDirectories(selCoolFolderPath)
Select Case Directory.GetFiles(foundDirectory, myCoolFileExtension).Length '// check File.Count.
Case 16
renameFiles(foundDirectory, myCool16File)
Case Else
' renameFiles(foundDirectory, myOtherFile)
End Select
getDirectoryList(foundDirectory, selCoolListBox)
Next
End Sub
Private Sub renameFiles(ByVal selCoolFolder As String, ByVal selFile As String)
arTemp = File.ReadAllLines(selFile) : iT = 0
For Each myCoolFile As String In My.Computer.FileSystem.GetFiles _
(selCoolFolder, FileIO.SearchOption.SearchTopLevelOnly, myCoolFileExtension)
If Not Path.GetFileName(myCoolFile) = arTemp(iT) Then
If Not File.Exists(Path.GetDirectoryName(myCoolFile) & "\" & arTemp(iT)) Then
My.Computer.FileSystem.RenameFile(myCoolFile, arTemp(iT))
Else
' //.error.More files in folder than there are file.names in .txt file.
Exit For
End If
End If
If Not iT = arTemp.Length - 1 Then
iT += 1
End If
Next
End Sub
End Class
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384