
Intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(App._file)) String jpgFilename = System.IO.Path.Combine(documentsDirectory, LeadId + AppResource.jpgExtension) Īpp._file = new File(documentsDirectory, jpgFilename) Intent intent = new Intent(MediaStore.ActionImageCapture)
IPICTURE APP CODE
I am using this code for creating app directory.
IPICTURE APP HOW TO
I am using GetExternalStoragePublicDirectory for saving image, it is working and the image is saved into the gallary, but I need it in the app directory, I read many posts and tried most of them and no good.Īlso can you tell me how to create directory and save. I am trying to capture and save an image from the camera to the app directory in Xamarin native Android. I was able to retrieve the images and display them later. Using (FileStream fs = new FileStream(pngFilename, FileMode.OpenOrCreate)) String pngFilename = System.IO.Path.Combine(documentsDirectory, imageName + ".png") Var photo = await renderer.LoadImageAsync(source, Forms.Context) Public async void SavePictureToDisk(ImageSource source, string imageName) Nevertheless I'll leave this code here in case it's usefull to anyone. I am not shure that this would have solved your problem, because you said the documentsDirectory was null, a problem i didn't have. The main error in your code was that in the FileStream line you used the documentsDirectory variable instead of the pngFilename variable, which was otherwise never used. The application exits SavePictureToDisk at line: When I run the app and click on the save button after the image is populated from the camera into an image control Using (FileStream fs = new FileStream(documentsDirectory, FileMode.OpenOrCreate)) String pngFilename = System.IO.Path.Combine(documentsDirectory, photoname + ".png") Var photo = await renderer.LoadImageAsync(imgSrc, Forms.Context)


Var renderer = new StreamImagesourceHandler() Public async void SavePictureToDisk(ImageSource imgSrc, string photoname) I have a Savebutton control on the MainPage, which suppose to call the SavePictureToDisk and saves the picture to the app directoryĭependencyService.Get ().SavePictureToDisk(imageSource, imageName) Void SavePictureToDisk(ImageSource imgSrc, string imagename) }
IPICTURE APP PORTABLE
Interface IPicture in the Portable Project: ImageSource = ImageSource.FromStream(() => mediaFile.Source) Var mediaFile = await mediaPicker.TakePhotoAsync(new CameraMediaStorageOptions This method is called from ButAddimage click event, opens the camera and saves the image to the Photos library: So far this was not successful, I am using Forms.Labs to take the image and it is working and the image is saved into the picture library folder, but I need it in the app directory, I read many posts and tried most of them and no good my code is so far like so:

I am trying to save an image from the camera to the app directory in Xamarin Forms Android.
