Slow response on file directory

D

Dennis English

Hi

The following code came be very slow in getting
creation time,filename,file length and directoryname
for files in a subdirectory because it keeps checking
each file sequentially in a slow DSL connection

Does anybody know how I can speed things? One suggestion
was to get the remote server to only bring back
creation time,filename,file length and directoryname of all
files in a subdirectory newer than a certain date, all in one shot.

_old code
Private Sub CheckPeMCopiedFilesAgainstDB()
Dim PemDir As IO.DirectoryInfo
Dim SubDir As IO.DirectoryInfo
Dim TypeDir As IO.DirectoryInfo
Dim PemFile As IO.FileInfo
Dim dtFiles As DataTable
dtFiles = CreateFileTable()
Dim drFile As DataRow
Dim dv As DataView

Dim ds As New DataSet()
Dim dtMaintDB As DataTable

Try
PemDir = New
IO.DirectoryInfo(Configuration.ConfigurationSettings.AppSettings.Item("pem_copies_file_path"))

For Each SubDir In PemDir.GetDirectories()
For Each TypeDir In SubDir.GetDirectories
For Each PemFile In TypeDir.GetFiles()
If PemFile.CreationTime >
Convert.ToDateTime(txtPemDate.Text) Then
drFile = dtFiles.NewRow
drFile("Folder") =
PemFile.DirectoryName
drFile("Create Date") =
PemFile.CreationTime
drFile("File Name") = PemFile.Name
drFile("Size") = PemFile.Length
dtFiles.Rows.Add(drFile)
End If
Next
Next
Next
 
R

Rudi

Not too sure if this will help, but you might want to look at the
DirectoryInfo.GetFileSystemInfos
method.
Returns an array of strongly typed FileSystemInfo entries listing all the
files and directories
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top