Hi all,

I am writing what SHOULD be a simple piece of code to read selected contents of several XML files into a master XML file. I have ensured that each file is opened, read and closed but always on the second iteration, I have a permission denied error from the script. Code below:

If oFSO.FolderExists(strTempFolder) Then
			Set oXML = oFSO.CreateTextFile (strXMLFile,1)
			oXML.WriteLine "<?xml version=""1.0"" encoding=""iso-8859-1""?>"
			oXML.WriteLine "<Spreadsheet>"
			set oFolder = oFSO.GetFolder(strTempFolder)
			icount = 1
			For each oFile in oFolder.Files
				WScript.Echo icount
				icount = icount + 1
				set oFullFile = oFSO.OpenTextFile(strTempFolder & oFile.Name,1,False) 'This is the location of the error
				strContents = oFullFile.ReadAll
				aSection1 = split(strContents,"<header>")
				aSection2 = split(aSection1(1),"</keys>")
				oXML.WriteLine "<entry>"
				oXML.WriteLine "<header>" & aSection2(0) & "</keys>"
				oXML.WriteLine "</entry>"
				set oFullFile = nothing
			oXML.WriteLine "</Spreadsheet>"
		End If
I would appreciate any help as I cannot find anything that would explain this issue (especially as it runs perfectly on the first iteration).