|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Folder loading problem.Hi
In my project, Using FindFirstFile,FindNextFile and FindClose APIs, i am loading the folders in to listbox (for ex c:\temp\). The problem is some of the clients having this problem,like in that particular folder they have nearly 50 Sub folders. but the api loads nearly 30 folders, its not loading the another 20 folders. it seems they all the folders property are same. i dont know why this happen. not all the clients. very few clients and all the systems in that particular clients. any idea please. Thanks bala Check whether it's not finding them at all, or whether it's finding them but
just not adding them to the listbox. To do this, replace your code that adds them to the listbox with Debug.Print and see if they get printed. If it's a problem with the listbox, post the code that adds them to the listbox. If it's not finding them at all, then post the code that finds the files. Show quoteHide quote "Bala" <B***@discussions.microsoft.com> wrote in message news:704D05F9-D087-4704-84F4-380CA5B8697B@microsoft.com... > Hi > > In my project, Using FindFirstFile,FindNextFile and FindClose APIs, i am > loading the folders in to listbox (for ex c:\temp\). The problem is some > of > the clients having this problem,like in that particular folder they have > nearly 50 Sub folders. but the api loads nearly 30 folders, its not > loading > the another 20 folders. it seems they all the folders property are same. i > dont know why this happen. not all the clients. very few clients and all > the > systems in that particular clients. any idea please. > > Thanks > bala Hi Bonj,
Thanks for the reply. Using fso, its loading all the folders into list. This is the code i am using in my project. i got it from here itself (ms vb fourm). Please check the code and let me know if did any mistake. Thanks Bala Code: 'Listbox loading speed functions Private Sub ListAllFoldersInDirectory(ByVal sPath As String, _ ByRef objListBox As ListBox) objListBox.Clear Dim wfd As WIN32_FIND_DATA Dim hfile As Long Dim sFileName As String If Right$(sPath, 1) <> "\" Then sPath = sPath & "\" hfile = FindFirstFile(sPath & "*.*", wfd) If hfile <> -1 Then With objListBox Do sFileName = TrimNull(wfd.cFileName) If Chr(Asc(sFileName)) <> "." Then If wfd.dwFileAttributes = vbDirectory Then .AddItem sFileName End If End If Loop Until FindNextFile(hfile, wfd) = 0 End With End If Call FindClose(hfile) End Sub Show quoteHide quote "Bonj" wrote: > Check whether it's not finding them at all, or whether it's finding them but > just not adding them to the listbox. > To do this, replace your code that adds them to the listbox with Debug.Print > and see if they get printed. > If it's a problem with the listbox, post the code that adds them to the > listbox. > If it's not finding them at all, then post the code that finds the files. > > > "Bala" <B***@discussions.microsoft.com> wrote in message > news:704D05F9-D087-4704-84F4-380CA5B8697B@microsoft.com... > > Hi > > > > In my project, Using FindFirstFile,FindNextFile and FindClose APIs, i am > > loading the folders in to listbox (for ex c:\temp\). The problem is some > > of > > the clients having this problem,like in that particular folder they have > > nearly 50 Sub folders. but the api loads nearly 30 folders, its not > > loading > > the another 20 folders. it seems they all the folders property are same. i > > dont know why this happen. not all the clients. very few clients and all > > the > > systems in that particular clients. any idea please. > > > > Thanks > > bala > > > See inline :-
On Fri, 27 May 2005 16:49:12 -0700, "=?Utf-8?B?QmFsYQ==?=" <B***@discussions.microsoft.com> wrote: Show quoteHide quote >Hi Bonj, /_______________/> >Thanks for the reply. Using fso, its loading all the folders into list. > >This is the code i am using in my project. i got it from here itself (ms vb >fourm). > >Please check the code and let me know if did any mistake. > >Thanks >Bala > >Code: > >'Listbox loading speed functions >Private Sub ListAllFoldersInDirectory(ByVal sPath As String, _ > ByRef objListBox As ListBox) > > objListBox.Clear > Dim wfd As WIN32_FIND_DATA > Dim hfile As Long > Dim sFileName As String > > If Right$(sPath, 1) <> "\" Then sPath = sPath & "\" > hfile = FindFirstFile(sPath & "*.*", wfd) > > If hfile <> -1 Then > With objListBox > Do > sFileName = TrimNull(wfd.cFileName) > If Chr(Asc(sFileName)) <> "." Then What on earth is that / It should be : If sFileName <> "." Then If sFileName <> ".." Then > If wfd.dwFileAttributes = vbDirectory Then If (wfd.dwFileAttributes And vbDirectory) = vbDirectory ThenIf you test for equality then you'll miss directories with the Archive bit set (32) and of course the ones with the Hidden and/or System bits set. Not to mention all the 'advanced' attributes. If this was originally posted here then whoever posted it needs a darn good kicking. Three serious bugs. As a matter of principle, I would return the results in an Array, this sort of code is not that speed critical, and it is useful to have totally re-useable code. Hi J French,
Thanks for the message... now i have changed the code like this.. is it Ok? please guide me. If Trim(sFileName) <> "." Then If Trim(sFileName) <> ".." Then If (wfd.dwFileAttributes And vbDirectory) = vbDirectory Then .AddItem sFileName End If End If End if Thanks bala Show quoteHide quote "J French" wrote: > See inline :- > > On Fri, 27 May 2005 16:49:12 -0700, "=?Utf-8?B?QmFsYQ==?=" > <B***@discussions.microsoft.com> wrote: > > >Hi Bonj, > > > >Thanks for the reply. Using fso, its loading all the folders into list. > > > >This is the code i am using in my project. i got it from here itself (ms vb > >fourm). > > > >Please check the code and let me know if did any mistake. > > > >Thanks > >Bala > > > >Code: > > > >'Listbox loading speed functions > >Private Sub ListAllFoldersInDirectory(ByVal sPath As String, _ > > ByRef objListBox As ListBox) > > > > objListBox.Clear > > Dim wfd As WIN32_FIND_DATA > > Dim hfile As Long > > Dim sFileName As String > > > > If Right$(sPath, 1) <> "\" Then sPath = sPath & "\" > > hfile = FindFirstFile(sPath & "*.*", wfd) > > > > If hfile <> -1 Then > > With objListBox > > Do > > sFileName = TrimNull(wfd.cFileName) > > If Chr(Asc(sFileName)) <> "." Then > /_______________/ > What on earth is that / > It should be : > If sFileName <> "." Then > If sFileName <> ".." Then > > If wfd.dwFileAttributes = vbDirectory Then > > If (wfd.dwFileAttributes And vbDirectory) = vbDirectory Then > > If you test for equality then you'll miss directories with the Archive > bit set (32) and of course the ones with the Hidden and/or System bits > set. Not to mention all the 'advanced' attributes. > > > If this was originally posted here then whoever posted it needs a darn > good kicking. Three serious bugs. > > As a matter of principle, I would return the results in an Array, this > sort of code is not that speed critical, and it is useful to have > totally re-useable code. > > > On Sat, 28 May 2005 09:21:01 -0700, "=?Utf-8?B?QmFsYQ==?="
<B***@discussions.microsoft.com> wrote: Show quoteHide quote >Hi J French, It looks Ok - but the two Trim()s are redundant> >Thanks for the message... now i have changed the code like this.. is it Ok? >please guide me. > >If Trim(sFileName) <> "." Then > If Trim(sFileName) <> ".." Then > If (wfd.dwFileAttributes And vbDirectory) = vbDirectory Then > .AddItem sFileName > End If > End If >End if > >Thanks >bala The TrimNull will have got the 'proper' file name Although it should not happen, there might be some devious way of creating a file/directory that is just a '.' with trailing/leading spaces. Incidentally (my fault) the logic should read: If (wfd.dwFileAttributes And vbDirectory) = vbDirectory Then If sFileName <> "." Then If sFileName <> ".." Then .AddItem sFileName This is because we are only interested in Directories, so that test should exclude other suspects /first/ i'll change that code. Thank you so much for your ideas.
-bala Show quoteHide quote "J French" wrote: > On Sat, 28 May 2005 09:21:01 -0700, "=?Utf-8?B?QmFsYQ==?=" > <B***@discussions.microsoft.com> wrote: > > >Hi J French, > > > >Thanks for the message... now i have changed the code like this.. is it Ok? > >please guide me. > > > >If Trim(sFileName) <> "." Then > > If Trim(sFileName) <> ".." Then > > If (wfd.dwFileAttributes And vbDirectory) = vbDirectory Then > > .AddItem sFileName > > End If > > End If > >End if > > > >Thanks > >bala > > It looks Ok - but the two Trim()s are redundant > > The TrimNull will have got the 'proper' file name > > Although it should not happen, there might be some devious way of > creating a file/directory that is just a '.' with trailing/leading > spaces. > > Incidentally (my fault) the logic should read: > > If (wfd.dwFileAttributes And vbDirectory) = vbDirectory Then > If sFileName <> "." Then > If sFileName <> ".." Then > .AddItem sFileName > > This is because we are only interested in Directories, so that test > should exclude other suspects /first/ > > > > Hi
i am having small doubt, 'If (wfd.dwFileAttributes And vbDirectory) = vbDirectory Then' This code will check the Archive is set 32 ? thanks bala Show quoteHide quote "J French" wrote: > On Sat, 28 May 2005 09:21:01 -0700, "=?Utf-8?B?QmFsYQ==?=" > <B***@discussions.microsoft.com> wrote: > > >Hi J French, > > > >Thanks for the message... now i have changed the code like this.. is it Ok? > >please guide me. > > > >If Trim(sFileName) <> "." Then > > If Trim(sFileName) <> ".." Then > > If (wfd.dwFileAttributes And vbDirectory) = vbDirectory Then > > .AddItem sFileName > > End If > > End If > >End if > > > >Thanks > >bala > > It looks Ok - but the two Trim()s are redundant > > The TrimNull will have got the 'proper' file name > > Although it should not happen, there might be some devious way of > creating a file/directory that is just a '.' with trailing/leading > spaces. > > Incidentally (my fault) the logic should read: > > If (wfd.dwFileAttributes And vbDirectory) = vbDirectory Then > If sFileName <> "." Then > If sFileName <> ".." Then > .AddItem sFileName > > This is because we are only interested in Directories, so that test > should exclude other suspects /first/ > > > > On Sun, 29 May 2005 10:08:01 -0700, "=?Utf-8?B?QmFsYQ==?="
<B***@discussions.microsoft.com> wrote: >Hi No the Archive attribute is tested for like this :-> >i am having small doubt, > >'If (wfd.dwFileAttributes And vbDirectory) = vbDirectory Then' > >This code will check the Archive is set 32 ? If (wfd.dwFileAttributes And vbArchive ) = vbArchive Then The basic attributes are the bits of a byte vbReadOnly 1 Read-only vbHidden 2 Hidden vbSystem 4 System vbDirectory 16 Directory or folder vbArchive 32 File has changed since last backup FindFirstFile will return all files, regardless of their attributes, it is up to you to filter out the 'types' that you don't want Don't like your with block, 'Call' syntax, explicit 'ByRef', method call
before declarations, etc. etc., but other than that it looks ok... does it work though was my question? Show quoteHide quote "Bala" <B***@discussions.microsoft.com> wrote in message news:0DDE9F52-0B28-4EDB-AA5F-595C6ACDDB8B@microsoft.com... > Hi Bonj, > > Thanks for the reply. Using fso, its loading all the folders into list. > > This is the code i am using in my project. i got it from here itself (ms > vb > fourm). > > Please check the code and let me know if did any mistake. > > Thanks > Bala > > Code: > > 'Listbox loading speed functions > Private Sub ListAllFoldersInDirectory(ByVal sPath As String, _ > ByRef objListBox As ListBox) > > objListBox.Clear > Dim wfd As WIN32_FIND_DATA > Dim hfile As Long > Dim sFileName As String > > If Right$(sPath, 1) <> "\" Then sPath = sPath & "\" > hfile = FindFirstFile(sPath & "*.*", wfd) > > If hfile <> -1 Then > With objListBox > Do > sFileName = TrimNull(wfd.cFileName) > If Chr(Asc(sFileName)) <> "." Then > If wfd.dwFileAttributes = vbDirectory Then > .AddItem sFileName > End If > End If > Loop Until FindNextFile(hfile, wfd) = 0 > End With > End If > Call FindClose(hfile) > > End Sub > > > > > > > "Bonj" wrote: > >> Check whether it's not finding them at all, or whether it's finding them >> but >> just not adding them to the listbox. >> To do this, replace your code that adds them to the listbox with >> Debug.Print >> and see if they get printed. >> If it's a problem with the listbox, post the code that adds them to the >> listbox. >> If it's not finding them at all, then post the code that finds the files. >> >> >> "Bala" <B***@discussions.microsoft.com> wrote in message >> news:704D05F9-D087-4704-84F4-380CA5B8697B@microsoft.com... >> > Hi >> > >> > In my project, Using FindFirstFile,FindNextFile and FindClose APIs, i >> > am >> > loading the folders in to listbox (for ex c:\temp\). The problem is >> > some >> > of >> > the clients having this problem,like in that particular folder they >> > have >> > nearly 50 Sub folders. but the api loads nearly 30 folders, its not >> > loading >> > the another 20 folders. it seems they all the folders property are >> > same. i >> > dont know why this happen. not all the clients. very few clients and >> > all >> > the >> > systems in that particular clients. any idea please. >> > >> > Thanks >> > bala >> >> >> i tried using debug.print, its not printing. thanks for ur help.
bala Show quoteHide quote "Bonj" wrote: > Don't like your with block, 'Call' syntax, explicit 'ByRef', method call > before declarations, etc. etc., but other than that it looks ok... does it > work though was my question? > > "Bala" <B***@discussions.microsoft.com> wrote in message > news:0DDE9F52-0B28-4EDB-AA5F-595C6ACDDB8B@microsoft.com... > > Hi Bonj, > > > > Thanks for the reply. Using fso, its loading all the folders into list. > > > > This is the code i am using in my project. i got it from here itself (ms > > vb > > fourm). > > > > Please check the code and let me know if did any mistake. > > > > Thanks > > Bala > > > > Code: > > > > 'Listbox loading speed functions > > Private Sub ListAllFoldersInDirectory(ByVal sPath As String, _ > > ByRef objListBox As ListBox) > > > > objListBox.Clear > > Dim wfd As WIN32_FIND_DATA > > Dim hfile As Long > > Dim sFileName As String > > > > If Right$(sPath, 1) <> "\" Then sPath = sPath & "\" > > hfile = FindFirstFile(sPath & "*.*", wfd) > > > > If hfile <> -1 Then > > With objListBox > > Do > > sFileName = TrimNull(wfd.cFileName) > > If Chr(Asc(sFileName)) <> "." Then > > If wfd.dwFileAttributes = vbDirectory Then > > .AddItem sFileName > > End If > > End If > > Loop Until FindNextFile(hfile, wfd) = 0 > > End With > > End If > > Call FindClose(hfile) > > > > End Sub > > > > > > > > > > > > > > "Bonj" wrote: > > > >> Check whether it's not finding them at all, or whether it's finding them > >> but > >> just not adding them to the listbox. > >> To do this, replace your code that adds them to the listbox with > >> Debug.Print > >> and see if they get printed. > >> If it's a problem with the listbox, post the code that adds them to the > >> listbox. > >> If it's not finding them at all, then post the code that finds the files. > >> > >> > >> "Bala" <B***@discussions.microsoft.com> wrote in message > >> news:704D05F9-D087-4704-84F4-380CA5B8697B@microsoft.com... > >> > Hi > >> > > >> > In my project, Using FindFirstFile,FindNextFile and FindClose APIs, i > >> > am > >> > loading the folders in to listbox (for ex c:\temp\). The problem is > >> > some > >> > of > >> > the clients having this problem,like in that particular folder they > >> > have > >> > nearly 50 Sub folders. but the api loads nearly 30 folders, its not > >> > loading > >> > the another 20 folders. it seems they all the folders property are > >> > same. i > >> > dont know why this happen. not all the clients. very few clients and > >> > all > >> > the > >> > systems in that particular clients. any idea please. > >> > > >> > Thanks > >> > bala > >> > >> > >> > > >
Accelerating Extraction of Bits From Text
Form VB 6 and MS-Word question Quotation mark as string How do you make child sub-commands visible in DataReport controls? Package/Deployment Wizard how to pass over events in stacked objects? Releasing lock on MDB file after DataReport1 closes One procedure for a textbox array? Can I develop VB6 App for windows CE? |
|||||||||||||||||||||||