H HARRY Active Member Licensed User Longtime User Sep 26, 2016 #1 Im am writing a KML file. When finished I write some closing details and then I close the textwriter: B4X: Expand Collapse Copy If what =3 Then Line= Tab2 & cFolderE TextWriter1.WriteLine(Line) Line= Tab1 & cFolderE TextWriter1.WriteLine(Line) Line=cKMLE TextWriter1.WriteLine(Line) TextWriter1.Close KMLOpened=False End If what =3 means finish and close the file. In debug mode I get an error message on the line TextWriter1.WriteLine(Line)( first one) saying that the textwriter is closed; in release mode the error message says that the textwriter should first be initialized. In debug mode the file is normally finished; in release mode the file is not visible in the relevant folder. Textwriter1 is no where else closed in the program. Am i doing something wrong?
Im am writing a KML file. When finished I write some closing details and then I close the textwriter: B4X: Expand Collapse Copy If what =3 Then Line= Tab2 & cFolderE TextWriter1.WriteLine(Line) Line= Tab1 & cFolderE TextWriter1.WriteLine(Line) Line=cKMLE TextWriter1.WriteLine(Line) TextWriter1.Close KMLOpened=False End If what =3 means finish and close the file. In debug mode I get an error message on the line TextWriter1.WriteLine(Line)( first one) saying that the textwriter is closed; in release mode the error message says that the textwriter should first be initialized. In debug mode the file is normally finished; in release mode the file is not visible in the relevant folder. Textwriter1 is no where else closed in the program. Am i doing something wrong?
lemonisdead Well-Known Member Licensed User Longtime User Sep 26, 2016 #2 Hello, I can't see something wrong here but, of course, you do Initialize it previously ? B4X: Expand Collapse Copy TextWriter1.Initialize(File.OpenOutput(File.DirDefaultExternal, MyFileName, True)) Upvote 0
Hello, I can't see something wrong here but, of course, you do Initialize it previously ? B4X: Expand Collapse Copy TextWriter1.Initialize(File.OpenOutput(File.DirDefaultExternal, MyFileName, True))
Erel B4X founder Staff member Licensed User Longtime User Sep 27, 2016 #3 Note that in most cases TextReader / TextWriter should be avoided as there are simpler solutions. In this case you can create a List and add the lines. Write it to a file with File.WriteList. Upvote 0
Note that in most cases TextReader / TextWriter should be avoided as there are simpler solutions. In this case you can create a List and add the lines. Write it to a file with File.WriteList.
H HARRY Active Member Licensed User Longtime User Sep 27, 2016 #4 Sorry, this was a programming error. The sub could be called twice. Harry Upvote 0