RE: Error 52 Bad file or file number
From: Darwin Abustan[MSFT] (darwina_at_online.microsoft.com)
Date: 11/23/04
- Next message: Srikanth Ganesan: "Least square Polynomial curve fit"
- Previous message: MikeD: "Re: Help Installing Custom Created VB OCX"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 23 Nov 2004 03:44:32 GMT
--------------------
>I have some code that will traverse through a folder/file structure and then create a similar representation of the structure as HTML. I open a file for output
(inc_CNILibrary.html) then traverse the tree and write to the file every time I encounter a folder or file. The LoadShareFolderTree function is recursive and calls itself
everytime a new folder is found. For no rhyme or reason, sometimes the code executes without a problem, other times it fails at different points in the traversal with the err52
message. Sometimes it fails after only a few lines have been written to the output file; other times after dozens of lines; other times it does not fail at all. Anyone have an
idea what could be causing the output file to get closed prematurely or VB to loose it's connection to the file handle?
fno = FreeFile
fname = App.Path & "\temp\" & pFName
Open fname For Output As #fno
'add the root folder
Set fld = fso.GetFolder(pPath)
Print #fno, "<p>"
For Each tFld In fld.SubFolders
Print #fno, tFld.Name & "<br>"
Next
If fld.SubFolders.Count > 0 Then
For Each tFld In fld.SubFolders
Call LoadShareFolderTree(tFld, intThisFolder, fno)
Next
End If
Print #fno, "Last Updated: " & Format(Now, "MM/DD/YY HH:NN")
Close #fno
Private Sub LoadShareFolderTree(prmFld As Folder, ByVal prmIndex As Integer, ByVal fno As Long)
...
Print #fno, SpacerWeb(prmIndex) & "<img src=images/folder.gif> " & prmFld.Name & "<br>"
>
Cannot deduce why this is happening with the code samples provided.
The following article provides an example of a scenario where you would receive Error '52'
PRB: Cannot Simultaneously Write to Disk File and Have It Opened in ActiveX DLL
http://support.microsoft.com/kb/q214674/
Darwin Abustan
Support Engineer
This posting is provided "AS IS" with no warranties, and confers no rights.
- Next message: Srikanth Ganesan: "Least square Polynomial curve fit"
- Previous message: MikeD: "Re: Help Installing Custom Created VB OCX"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|