Its filled before with the data...the value is written correct, but no appending.
I also tried other Directories like C:\Test, but also the same result
Its filled before with the data...the value is written correct, but no appending.
I also tried other Directories like C:\Test, but also the same result
Its filled before with the data...the value is written correct, but no appending.
I also tried other Directories like C:\Test, but also the same result
Dim inStr As InputStream = File.OpenInput(File.DirApp, "sample.txt")
Dim outStr As OutputStream = File.OpenOutput(File.DirApp, "test.txt", True)
File.Copy2(inStr, outStr)
outStr.Close
Lol I am so late to this party, but... I've already written this up, so here it is in case it's of use:
B4X:
Sub FileAppendString(FileDir As String, FileName As String, NewString As String)
Dim NewBytes() As Byte = NewString.GetBytes("UTF8")
Dim fh As OutputStream = File.OpenOutput(FileDir, FileName, True)
fh.WriteBytes(NewBytes, 0, NewBytes.Length)
fh.Close
End Sub
Sub FileAppendLine(FileDir As String, FileName As String, NewLine As String)
FileAppendString(FileDir, FileName, NewLine & CRLF)
End Sub
Public Sub Schreibpreis(str As String)
Try
Dim tmpTextWriter As TextWriter
DateTime.DateFormat = "dd.MM.yyyy"
DateTime.TimeFormat = "HH:mm:ss"
If File.Exists(File.DirApp, "test.txt") = True Then
End If
tmpTextWriter.Initialize(File.OpenOutput(File.DirApp, "test.txt", True))
tmpTextWriter.WriteLine(DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now) & " " & myString)
tmpTextWriter.Close
Catch
Log("Error: Write Error Log " & LastException.Message)
End Try
End Sub
Here is my sub. Not sure I created myself or copied it from somewhere else.
B4X:
Sub WriteTextOutput (Dir As String, FileName As String, Contents As String)
Dim Out As OutputStream = File.OpenOutput(Dir, FileName, True)
Dim b() As Byte = (CRLF & Contents).GetBytes("UTF8")
Out.WriteBytes(b, 0, b.Length)
Out.Close
End Sub