protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile); Uri contentUri = Uri.FromFile(App._file); mediaScanIntent.SetData(contentUri); SendBroadcast(mediaScanIntent); var options = new BitmapFactory.Options(); options.InJustDecodeBounds = true; options.InPurgeable = true; // Calculate inSampleSize options.InSampleSize = 4; // Decode bitmap with inSampleSize set options.InJustDecodeBounds = false; options.InPurgeable = true; Bitmap bitmap = BitmapFactory.DecodeFile(App._file.Path, options); //Ha dado boton atras y no ha hecho foto if (bitmap != null) { Matrix matrix = new Matrix(); matrix.PostRotate(90.0f); // La rotación debe ser decimal (float o double) viene girada y asi la pongo recta bitmap = Bitmap.CreateBitmap(bitmap, 0, 0, bitmap.Width, bitmap.Height, matrix, true); byte[] bitmapData; using (var ms = new System.IO.MemoryStream()) { bitmap.Compress(Bitmap.CompressFormat.Jpeg, 90, ms); bitmapData = ms.ToArray(); } TRAtaMeWS.TRAtaMeWS TRAtaMe = new TRAtaMeWS.TRAtaMeWS(); string mensaje = ""; TRAtaMe.mover_fichero(bitmapData, "F", ".jpg", datos_usuario, datos_paciente, ref datos_informacion, ref mensaje); while (mensaje == "") { //Mientras no haya terminado de subir el fichero (mensaje = "FINAL"==>OK) o mensaje = "mensaje de error" } if (mensaje != "FINAL") { object CrLf = System.Environment.NewLine; ShowAlert("ERROR", "No ha subido el archivo " + CrLf + mensaje, "S"); } string basePath = Android.App.Application.Context.GetExternalFilesDir(null).AbsolutePath; File[] files = Environment.GetExternalStoragePublicDirectory((Environment.DirectoryDcim) + "/Camera/").ListFiles(); string fichero = ""; string fecha = DateTime.Now.ToString("yyyyMMdd"); int ind = 9999; for (int i = 0; i < files.Count(); i++) { if (files[i].Name.Substring(0, 8) == fecha) { if (string.Compare(files[i].AbsolutePath, fichero) == 1) { ind = i; } } } if (ind != 9999) { files[ind].Delete(); } App._file.Delete(); Mostar_Foto(); GC.Collect(); } }