c# - Cannot find file path - image -
i trying send image on ftp on android. tried lot of possible ways accomplish that, , same problem persists: error telling path/directory/file doesn't exist.
my code right using camerasample xamarin , getting picture taken camera , trying send on ftp. when try that, receive error:
enoent (no such file or directory)
here code:
protected override void onactivityresult(int requestcode, result resultcode, intent data) { base.onactivityresult(requestcode, resultcode, data); // make available in gallery intent mediascanintent = new intent(intent.actionmediascannerscanfile); uri contenturi = uri.fromfile(_file); system.console.writeline (contenturi.tostring ()); mediascanintent.setdata(contenturi); sendbroadcast(mediascanintent); // display in imageview. resize bitmap fit display // loading full sized image consume memory // , cause application crash. int height = _imageview.height; int width = resources.displaymetrics.widthpixels; using (bitmap bitmap = _file.path.loadandresizebitmap(width, height)) { _imageview.recyclebitmap (); _imageview.setimagebitmap(bitmap); } thread t = new thread ( () => uploadtoftp(contenturi.tostring())); t.start (); } private void uploadtoftp(string uri){ simpleftp ftp = new simpleftp (); ftp.connect("xxx.xxxxx.xxx", 21, "xxxxxxx", "xxxxxxxx"); ftp.stor (new file(uri)); ftp.disconnect(); }
does have ideia happening? i've tried assets/drawable/files etc. , nothing works. the image can seen on imageview.
the path printed on console one:
file:///storage/sdcard0/pictures/cameraappdemo/myphoto_64ee3fec-08af-4bde-9214-62892b6d9f72.jpg
thanks
edit: figured out... problem use of contenturi.tostring()
instead of contenturi.path
, latter result correct , without "file://" part, should that:
/storage/sdcard0/pictures/cameraappdemo/myphoto_64ee3fec-08af-4bde-9214-62892b6d9f72.jpg
Comments
Post a Comment