Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

File.Exists always fails

$
0
0

I'm playing with an app that will load images from an sd card. I am running in debug mode in VS 2012 and running on a Motorola Xoom tablet (Android 4.1.2). I have placed the images at the root of the card and in a subdirectory called Images. I have tried a couple of different tweaks to the code but essentially .Exists always fails (no exception though).

` var sdCardpath = Android.OS.Environment.ExternalStorageDirectory.Path; var imageFilePath = System.IO.Path.Combine(sdCardpath, "Plate1.jpg");

            // File imgFile = new File(imageFilePath);
            // if (imgFile.Exists())

            if (System.IO.File.Exists(imageFilePath))
            {
                var imageFile = new Java.IO.File(imageFilePath);

                Bitmap myBitmap = BitmapFactory.DecodeFile(imageFile.AbsolutePath);

                ImageView myImage = (ImageView)FindViewById<ImageView>(Resource.Id.imageView1);
                myImage.SetImageBitmap(myBitmap);
            }

`

I tried deploying the app to the tablet and it still fails to load the images. I have turned on WRITE_EXTERNAL_STORAGE in the manifest. I have used the SanDisk app to verify the files are there and that the default viewer can open them. I'm sure its something simple just not sure where to look.

Thanks


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>