Delphi save text file on Android -
i have upload text file on android project , used idftp
. code:
button2.enabled:=false; label5.text:='uploading...'; memo1.lines.add(edit1.text+':'+combobox1.items.text); memo1.savetofile('filehost.txt'); try idftp1.connect; // set host, password , username idftp1.put('filehost.txt'); idftp1.disconnect;
i having problem because when run app on samsung (android 2.3) have error says cannot create file "/filehost.txt". not directory
.
i must save content of memo1 in android device , upload using idftp. how can avoiding error?
you can't write root folder. use tpath
find writable folder, such tpath.gettemppath()
or tpath.getdocumentspath()
.
alternatively, not use file @ all. tidftp.put()
has overloaded version uploads tstream
instead of file, eg:
var ms: tmemorystream; begin ms := tmemorystream.create; try memo1.lines.savetostream(ms); ms.position := 0; ... idftp1.put(ms, 'filehost.txt'); ... ms.free; end; end;
Comments
Post a Comment