Is there a limitation on amount of files i can write?

Hi;

I’m working with a database of 4,686 documents. I wrote a script that pulls information of of each document and creates a text file with the Employee ID number as the filename.

It is supposed to place each file in a folder on the network. However, when the script has created 252 files i get a message saying “Cannot open File”

I’m hitting some kind of limitation, is there a way around this?

Subject: is there a limitation on amount of files i can write?

No, even if there were a limit it would be waaaay above 252 files.Post your code so we can have a look.

Subject: RE: is there a limitation on amount of files i can write?

Here’s what the code looks like…

Sub Initialize

	'Dim aLog As NotesLog

Dim db As NotesDatabase

Dim filenum As Integer, I As Integer	

Dim filename As String

Dim Path As String, form As String

Dim workspace As NotesUIWorkspace

Dim collA  As NotesDocumentCollection

Dim collB As NotesDocumentCollection

Dim doc, response As NotesDocument

Dim s As New NotesSession

Dim IDNum As Variant, edu As Variant, IDnum2 As Variant

Dim Certifications As Variant, security As Variant, history As Variant

Dim publications As Variant, memberships As Variant, devtools As Variant

Dim appProtocols As Variant, CabPlant As Variant, dbsystems As Variant

Dim emgrpware As Variant, hdware As Variant, lanwan As Variant

Dim netmgmt As Variant, nos As Variant, nprot As Variant

Dim gdexp As Variant

Dim opsys As Variant, plang As Variant

Dim eng1 As Variant, eng2 As Variant

Dim eng3 As Variant, eng4 As Variant

Dim view As NotesView

Dim item As NotesItem

Dim dt As notesdatetime





Set aLog = New NotesLog("Database log")	

Set db = s.CurrentDatabase	

Set view = db.GetView("Employee Resumes")

Set doc = view.GetFirstDocument



Set response = view.GetChild(doc)

Chdrive "C"



While Not (doc Is Nothing)

	Chdir "c:\EresData2"

	

	IDNum = doc.GetItemValue( "EmpNumber" )

	

	If IDNum(0) = "000000"  Or "00000" Then

		Set doc = view.GetNextDocument(doc)

	End If

	

	'If doc.HasEmbedded Then

'****************************************************************

	'Info from Resume Form

	edu = doc.GetItemValue("Education")

	history = doc.GetItemValue("emphistory")

	security = doc.GetItemValue("security")

	publications = doc.GetItemValue("publications")

	memberships = doc.GetItemValue("memberships")

	'end data from resume form

'*********************************************************************

	filename$ = IDnum(0) & ".txt"

	filenum% = Freefile()

	Open filename$ For Output As filenum%

	If edu(0) <> "" Then

		Write #filenum%, "Education: " & edu(0) & "#\"

	End If

	If security(0) <> "" Then

		Write #filenum%, "Security Clearance: " & security(0) & "#\"

	End If

	If publications(0) <>"" Then

		Write #filenum%, "Publications, Awards, Honors: " & publications(0) & "#\"

	End If

	If memberships(0) <> "" Then

		Write #filenum%, "Associations: " & memberships(0) & "#\"						

	End If	

	If history(0) <> "" Then

		Write #filenum%, "Other Work Experience: " & history(0) & "#\"

	End If

	

	IDnum2 = doc.GetItemValue( "EmpNumber" )

	formname = doc.GetitemValue("form")

	If IDNum2(0) <> IDNum(0)  & formname(0) = "Technical Skills" Then				

		Close #fileNum%			

		Set doc = view.GetNextDocument( doc )

	Else

'***********************************************************************

'Engineering section starts here - goes to Certifications and Licenses

		eng1 = response.GetItemValue("Engineering1")

		eng2 = response.GetItemValue("OtherEDisc")

		eng3 = response.GetItemValue("Engineering2")

		eng4 = response.GetItemValue("OtherESkills")

		'End of engineering section

'**************************************************************************

		Certifications = response.GetItemValue("Certifications")

		appProtocol = response.GetItemValue("apchoicesall")

		dbsystems = response.GetItemValue("dbchoicesall")

		devtools = response.GetItemValue("devchoicesall")

		emgrpware = response.GetItemValue("gwchoicesall")

		hdware = response.GetItemValue("hdchoicesall")

		lanwan = response.GetItemValue("lanchoicesall")

		netmgmt = response.GetItemValue("nmchoicesall")

		nos = response.GetItemValue("noschoicesall")

		nprot = response.GetItemValue("npchoicesall")

		opsys = response.GetItemValue("oschoicesall")

		plang = response.GetItemValue("lgchoicesall")

		

		

		Write #filenum%,  "Certifications& Licenses: " & Certifications(0) & " ", eng1(0) <> " " & " " , eng2(0) & " ", eng3(0) & " ", eng4(0) & " " & "#\"

		

		Write #filenum%,  "Expertise/Skill Summary: " & appProtocol(0) & " ",  dbsystems(0) & " ",  devtools(0) & " ", emgrpware(0) & " ",_ 

		hdware(0) & " ", lanwan(0) & " " ,netmgmt(0) & " ",  nos(0) & " " , nprot(0) & " ", opsys(0) & " ", plang(0) & " ", "#\"

		

	End If

	Close #fileNum%		

	

	Set doc = view.GetNextDocument(doc)

	If doc.IsResponse Then

		Set doc = view.GetNextDocument(doc)

	End If

	

Wend

End Sub

Subject: Its the call to Freefile()

I’ve seen this before.I don’t think its a Notes limit, but a limit of your operating system.

You’ve probably got a limit of 256 file handles (and have 4 open already with nnotes.exe, Notes.ini, notes log, etc)

Move the call to freefile() outside the While Wend loop. Use the same file number repeatedly.

Subject: RE: Its the call to Freefile()

Thanks, that would make sense.

What do you mean by use the same file number repeatedly?

Subject: RE: Its the call to Freefile()

Just make the following change:

filenum% = Freefile()

While Not (doc Is Nothing)

Then delete the line where you set filenum later in the loop. As long as you’re closing the file at the end of the loop (which you are), you don’t need to get a new file handle every time.

Subject: RE: Its the call to Freefile()

Thanks…

I will try this tomorrow when I go back to the office.

Subject: RE: Its the call to Freefile()

Hi charles…

I tried your solution and it still restricts me to 252 files…

Subject: Try manually creating some files to see if you have a limit

Perhaps you’re running into a file system imposed limit. Can you try created more than 252 files manually in the directory? What may appear to be the number of files, could it be the total size? Just throwing some thoughts out there…

Subject: RE: Try manually creating some files to see if you have a limit

Ah, that does ring a bell. I know in a root directory on Windows you can only have 255 total entries, and Windows uses 2 or 3 of those. In his code he is changing to another directory, but I wonder if this is somehow still causing the problem.

Good catch!

Subject: RE: Try manually creating some files to see if you have a limit

Ok guys i figured what it was…

this line:

Dim filenum As Integer

filenum should be dimmed as long

which gives u the ability to create a few million files…

Thanks for all your help.

LP

Subject: RE: Try manually creating some files to see if you have a limit

An integer goes up to 32K, not 251. And you said you were NOT regenerating the file handle with each iteration, so filenum was only being instantiated once, probably with a 1 or 2. I’m glad you solved your issue, but I have a sneaking suspicion we didn’t get all the details.