Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

File locations and File.Exists

$
0
0

Hi,

I've tried every conceivable way (I think), to determine if a file exists, and I can't produce consistent results. It randomly works/fails.

I've tried:

//testing only
                var documentsPathOne = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                var filePathOne = Path.Combine(documentsPathOne, fileName);
                bool doesTypeOneExist = File.Exists(filePathOne);

                if (!UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    var OtherDocumentsPath = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User)[0];
                    var filePathTwo = Path.Combine(OtherDocumentsPath.AbsoluteUrl.ToString(), fileName);
                    bool doesTypeTwoExist = File.Exists(filePathTwo);
                }

                bool doesTypeThreeExist = File.Exists(filePath);

The strange thing is this typeThree is a DIRECT result from the media picker, and using it in the context of an Image Control works, i.e.:

Image.Source = filePath Works perfectly and the image is displayed - so I know it exists and is there.

Can anyone help me with using files in iOS? It's crazy!

Thanks


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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