Visual Basic/VB6

Advertisement


Question
QUESTION: Dear Sir, I am intermediate level programmer,my question is i want to list all the files from several folders inside a Main folder in listview or any control and when ever there is a new file added to any folder or renamed any files or deleted any file, automatically the listview should be updated with the changes in any folder.
please help me in this regards sir.Thanking u so much sir.

ANSWER: you need to run this programme after a file has been added then it can identify all files including the latest file added. Obviously the list cannot be updated if this vb exe is Not run.

---------- FOLLOW-UP ----------

sample
sample  
QUESTION: Yes Mr.Ravindra, it is working fine if i run, but i have 3000 files from different folders, it is taking long time to load all files again. I just do not need to load all files again.i need only the new files,changes should be reflected. I have seen a application which load all files from several folders and i can see immediately the status of any file changes in any folder without taking even 2 seconds. I wonder how it is possible.
Please see the snapshot for better understanding.In this pic the first file with Pending status will change to Completed soon and i can see changes immediately.Please help me sir.

Answer
one solution would be to load the previously loaded files of the listbox into a text file; load these files from the textfile onto the listbox and append the latest file from a given date:

the code would be like this:
Dim MyStamp As Date
Private Sub Command1_Click()
   Dim strStartPath As String
   strStartPath = "F:\Current" 'ENTER YOUR START FOLDER HERE
   ListFolder strStartPath
End Sub

Private Sub ListFolder(sFolderPath As String)
   Dim FS As New FileSystemObject
   Dim FSfolder As Folder
   Dim File As File
   Dim i As Integer
   Dim temp As Date
   Set FSfolder = FS.GetFolder(sFolderPath)
   Text1.Text = ""
    Dim testDate As Date
    testDate = "06/18/2014"
       For Each File In FSfolder.Files

     MyStamp = Format(FileDateTime(File), "DD-MMM-YY")
 
      If MyStamp > testDate Then
       DoEvents
       Text1.Text = Text1.Text & File & Space(5) & MyStamp & vbCrLf
   End If
   Next File
   Set FSfolder = Nothing
End Sub


Try it out and make some changes as you need. you need to change the date and folder path which could be chosen from a listbox or textbox

Visual Basic

All Answers


Answers by Expert:


Ask Experts

Volunteer


Ravindra

Expertise

visual basic application programming from design to access information, sql, engineering and commercial applications. access databases, excel.(VB6) basic questions in vb 2008. Optional: 1)a large number of people want me to do work which takes some time and effort. can do projects in vb 2008. Pl.note that i would like to be paid for such work. 2) if you want me to spend quality time and do special work, i expect to be paid a reasonable price for my time. 3) if you are pleased with my reply you could consider a good amount. 4) you can visit my website http://ravindra.coolpage.biz

Experience

programming since the past 15 years. have completed a large number of projects in Industrial applications, finance,accounts, correspondence. excel macros etc

Education/Credentials
engineering, management degrees.

Past/Present Clients
project work for a Norway company,USA company and a Canadian company completed. Freelance Project work and Teaching. helping programmers with their work
teaching vb

©2016 About.com. All rights reserved.