How to use Internal Storage of Android in Xamarin? -
i want able use android's internal storage. found code snippets like:
string path = application.context.filesdir.path; var filepath = path.combine(path, "test.txt"); system.io.file.writealltext(filepath, "hello world");
but not figure out application in here.
is there solution or different perspective? :)
use this:
string path = system.environment.getfolderpath(system.environment.specialfolder.personal); string filename = system.io.path.combine(path, "testfile.txt"); // write using (var streamwriter = new streamwriter(filename, true)) { streamwriter.writeline(datetime.utcnow); } // read using (var streamreader = new streamreader(filename)) { string content = streamreader.readtoend(); system.diagnostics.debug.writeline(content); }
Comments
Post a Comment