This project has moved. For the latest updates, please go here.

Problem with file: uri

Dec 5, 2013 at 3:09 AM
Hi Clemens et all,

I´ve been using 1.3.8 version with file: uri without problems. Today I´ve moved to the latest version and noticed that this types of uri are not recognized.
What I see is that:
        private static ImageSource CreateImage(string path)
        {
            ImageSource image = null;

            if (File.Exists(path))
            {
                try
                {
                    using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
                    {
                        image = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                    }
                }
                catch (Exception ex)
                {
                    Trace.TraceWarning("Creating tile image failed: {0}", ex.Message);
                }
            }

            return image;
        }
fails on the File.Exists check.

For exmaple, when calling the method with:
path="C:/Users/fsaux/Documents/My%20Maps/SHN/5/11/13.png"
Which exists on my local drive, the check will return false.

Any clue why could this be happening?

Thanks & regards,
Fernando.
Coordinator
Dec 5, 2013 at 8:20 AM
Hi Fernando,

The problem is that the current version uses Uri.AbsolutePath to get the local file name, which does not replace %20 by a space character. It should use Uri.LocalPath instead. I will provide a new release tonight, which fixes the problem.

Cheers
Clemens
Dec 5, 2013 at 10:36 AM
Thanks Clemens ... and sorry, I´ve just noticed that this was already discussed on the previous thread.
Coordinator
Dec 5, 2013 at 4:03 PM
Please check out the latest version.