Link to home
Start Free TrialLog in
Avatar of rajender123
rajender123

asked on

Displat files, files path and size in list box

I have pdf files in my d:\test folder.

I want to display all the files,  size and the  path of files in list box....

Can i use list box or let me know if any other control can be used to display.................... in VB

additionally i want to display the   headers as  filename, Infolder and size..
how will i do in VB
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

check and customize this sample:

FindFirstFile: Recursive File Search for Single or Multiple File Types
http://vbnet.mvps.org/code/fileapi/recursivefiles_minimal_multiple.htm

to get the file size, you can try use the FileLen function, like:

filelen(yourfilepath)
Avatar of rajender123
rajender123

ASKER

No  this  does not help my problem...

I am using list box... and on the click of button i am able to  display the  file name... using this code


Dim oFs As New FileSystemObject
Dim sAns() As String
Dim oFolder As Folder
Dim oFile As File
Dim lElement As Long

Dim X, lngbytes, y

ReDim sAns(0) As String
If oFs.FolderExists(Text1.Text & "\") Then
    Set oFolder = oFs.GetFolder(Text1.Text & "\")
   For Each oFile In oFolder.files
      lElement = IIf(sAns(0) = "", 0, lElement + 1)
      ReDim Preserve sAns(lElement) As String
       sAns(lElement) = oFile.name

list1.additem (ofile.name)
Next

End If


but, i want that the  list box should have three cols:-

1) File name
2) File Path
3) Size

I know in list box we should  have always one data.. what if i use Datagrid or  msflex grid????

can i get the information in any other controls.. with the  names of the cols as  i have mentioned  and the  files from the folder......................in VB only

please let me know
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes.. thanks . ryan.. it works ...

But  when i click on file name... it will  only highlight file name.............

can  we highlight complete row ... say if i select   first file.... it will highlight the filepath and file size  also.................................

cant we highlight the complete   row in list view....


actually the client wants the complete  row to  be highlighted if the user selects any file.............................

Is there any othere way round for this.............in VB

please guys  help me in this
try add this into your Form_Load() event:

ListView1.FullRowSelect = True
No there is no property in List view  like this ..............................................

 This is not working...

Please let me know how will i do that......... or in case is there any other control in VB we can use


please lete me know asap
Are you using VB6 or VB.NET ?