Why i can’t open 2 files in writing mode?
Im trying to do the following code:
Dim file1 As Integer
Dim file2 As Integer
file1% = Freefile()
file2% = Freefile()
OutputFile1 = "d:/teste1.xml"
FileExists = Dir$( OutputFile1, 0 )
OutputFile2 = "d:/teste2.xml"
FileExists = Dir$( OutputFile2, 0 )
Open OutputFile1 For Output As file1%
Open OutputFile2 For Output As file2%
Close file1%
Close file2%
Note: Both files doesn’t exists. Im trying to create them.
The error that appears to me is:
File already open on line number 13 ==> (Open OutputFile2 For Output As file2%)
any ideas? thank you!!
Subject: Try another way:
OutputFile1 = "d:/teste1.xml" FileExists = Dir$( OutputFile1, 0 )
OutputFile2 = "d:/teste2.xml"
FileExists = Dir$( OutputFile2, 0 )
file1% = Freefile()
Open OutputFile1 For Output As file1%
file2% = Freefile()
Open OutputFile2 For Output As file2%
Subject: Opening 2 files in write mode
You can – the problem is that Freefile will return the same value both times unless you open a file between calls. So you have to open file 1 before you can get a valid filenumber for file 2.
Subject: RE: Opening 2 files in write mode
Thanks Bill and Stan, for the solution and the explanation!! Now it´s working!! Cya!!