PCLStorage icon indicating copy to clipboard operation
PCLStorage copied to clipboard

Write many lines in file

Open luisolarte opened this issue 9 years ago • 3 comments

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(); } }

luisolarte avatar Jul 22 '15 16:07 luisolarte

Exactly my question is How can I Append text to file using PCLStorage? I'm agree with your answer

luisolarte avatar Jul 23 '15 12:07 luisolarte

Try seeking to the end of the stream before writing to it.

dsplaisted avatar Jul 23 '15 21:07 dsplaisted

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.

luisolarte avatar Jul 23 '15 21:07 luisolarte