Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27034

VS 2005 use one "for ....next" for this function

$
0
0
how can i merge this two for looping in one or how can i improve this code to seek file and folders

Code:

Try
            Dim folders() As String = IO.Directory.GetDirectories(path)
            Dim files() As String = IO.Directory.GetFiles(path)
            For i As Integer = 0 To folders.Length - 1
                datax.Rows.Add()
                datax.Rows(i).Cells("time").Value = Format(Now, "HH:mm:ss")
                datax.Rows(i).Cells("file").Value = folders(i)
                Try
                    My.Computer.FileSystem.GetDirectoryInfo(folders(i)).Attributes = IO.FileAttributes.Normal
                    ShowAll(folders(i))
                Catch ex As Exception
                    datax.Rows(i).Cells("result").Value = "Failed"
                End Try
            Next
            For i As Integer = 0 To files.Length - 1
                datax.Rows.Add()
                datax.Rows(i).Cells("time").Value = Format(Now, "HH:mm:ss")
                datax.Rows(i).Cells("file").Value = files(i)
                runsome.ReportProgress(i * 10)
                Try
                    My.Computer.FileSystem.GetFileInfo(files(i)).Attributes = IO.FileAttributes.Normal
                    ShowAll(files(i))
                Catch ex As Exception
                    datax.Rows(i).Cells("result").Value = "Failed"
                End Try
            Next
        Catch ex As Exception
            MsgBox(ex, MsgBoxStyle.Information, "ToudraShow")
        End Try

and thank you

Viewing all articles
Browse latest Browse all 27034

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>