PCLStorage
PCLStorage copied to clipboard
Write many lines in file
Hi for everybody
I'm not sure if this issue is my error or a library error, but i'm trying to write a file log, but the funcion overwrite the first line always, initialy i was using the funcion IFile.WriteAllTextAsync(text) but it overwrite but if i use a streamwriter, the file no change, this is my code.
the file object is the type IFile
using (var stream = await file.OpenAsync(FileAccess.ReadAndWrite)) { using (var writer = new StreamWriter(stream)) { writer.WriteLine(data); writer.Flush(); } }
Exactly my question is How can I Append text to file using PCLStorage? I'm agree with your answer
Try seeking to the end of the stream before writing to it.
Hi Daniel thanks for your answer
I'm working in PCL context and in this, the function seek doesn't exist, I'm trying use the StreamWriter builder with path and boolean to append but doesn't exist, I hope to find a solution with the PCLStorage, but the examples I've seen about how to use only works with one read and one write, replacing the files.