Hi, i am Kobs
Please could you help me? i am new in programming and i want to know what’s wrong with these codes? I want to count the number of files inside a folder, like how many *.dat file type inside the given path folder
dim filepath As String = “C:Gasresult”
Dim dirInfo As New System.IO.DirectoryInfo(filepath)
Dim intCount As Integer = Nothing
Dim str As Integer = Nothing
‘Dim int1 As Integer = Nothing
For Each files In dirInfo.GetFiles
If dirInfo.Extension(files.FullName) = “dat” Then
intCount = Convert.ToInt32(dirInfo)
intCount = intCount + 1
End If
Next files
MsgBox(intCount)
everytime i execute the code, it always give me the error message >> conversion from string ….. to integer type is not valid or invalid
Please help! very much appreciated! thanks!
ps: im using vb.net