Hi all,
I'm trying to change the file extensions of some excel files to csv and add the file names to a list box. The box is coming up blank however.
My code is as follows:
Private Sub Project_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim importsFileList As New ArrayList
Dim sFile As String
Dim extension As String
Dim newExtension As String
sFile = Dir$("C:\Users\filepath" & "\*.*", vbDirectory)
Do Until sFile = vbNullString
If sFile <> "." Then ' relative path meaning this directory
If sFile <> ".." Then ' relative path meaning parent directory
extension = IO.Path.GetExtension(sFile)
If extension = ".xls" Or extension = ".xlsx" Then
Dim fInfo As IO.FileInfo = New IO.FileInfo(sFile)
newExtension = IO.Path.ChangeExtension(sFile, ".csv")
fInfo.MoveTo(newExtension)
End If
End If
End If
sFile = Dir$()
Loop
sFile = Dir$("C:\Users\filepath" & "\*.*", vbDirectory)
Do Until sFile = vbNullString
If sFile <> "." Then ' relative path meaning this directory
If sFile <> ".." Then ' relative path meaning parent directory
extension = IO.Path.GetExtension(sFile)
If extension = ".csv" Then
importsFileList.Add(sFile)
End If
End If
End If
sFile = Dir$()
Loop
For Each importedFile In importsFileList
ImportFiles.Items.Add(importedFile)
Next
Where am I going wrong?
Thanks in advance for any suggestions offered.