Why does File.Exists return false?

Posted by Jonas Stawski on Stack Overflow See other posts from Stack Overflow or by Jonas Stawski
Published on 2012-10-11T21:34:34Z Indexed on 2012/10/11 21:36 UTC
Read the original article Hit count: 217

Filed under:
|

I'm querying all images on the Android device as such:

string[] columns = { MediaStore.Images.Media.InterfaceConsts.Data, 
            MediaStore.Images.Media.InterfaceConsts.Id };
string orderBy = MediaStore.Images.Media.InterfaceConsts.Id;
var imagecursor = ManagedQuery(MediaStore.Images.Media.ExternalContentUri, columns, null, null, orderBy);
for (int i = 0; i < this.Count; i++) {
    imagecursor.MoveToPosition(i);
    Paths[i]= imagecursor.GetString(dataColumnIndex);
    Console.WriteLine(Paths[i]);
    Console.WriteLine(System.IO.File.Exists(Paths[i]));
}

The problem is that the output shows that some files don't exist. Here's a sample output:

/storage/sdcard0/Download/On-Yom-Kippur-Jews-choose-different-shoes-VSETQJ6-x-large.jpg
False
/storage/sdcard0/Download/397277_10151250943161341_876027377_n.jpg
False
/storage/sdcard0/Download/Roxy_Cottontail_&_Melo-X_Present..._Some_Bunny_Love's_You.jpg
False
/storage/sdcard0/Download/album-The-Rolling-Stones-Some-Girls.jpg
True
/storage/sdcard0/Download/some-people-ust-dont-appreciate-fashion[1].jpg
True
/storage/sdcard0/Download/express.gif
True
...
/storage/sdcard0/Download/some-joys-are-expressed-better-in-silence.JPG
False

How is this possible? I downloaded these images myself from the internet! They should exist in disk.

© Stack Overflow or respective owner

Related posts about android

Related posts about monodroid