Access Denied :Unauthorised ExCeption

0

The following error occurred in my project, can anyone tell me how to solve this exception?

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) in windows phone 8.1.

I have this code:

using (IRandomAccessStream readStream = await file.OpenAsync(FileAccessMode.Read))




        StorageFile file = usertoken ;
        try
        {
            if (file != null)
            {
                using (IRandomAccessStream readStream = await file.OpenAsync(FileAccessMode.Read))
                {
                    using (DataReader dataReader = new DataReader(readStream))
                    {
                        UInt64 size = readStream.Size;

                        UInt32 numBytesLoaded = await dataReader.LoadAsync((UInt32)size);
                        string fileContent = dataReader.ReadString(numBytesLoaded);
                        return (bool)true;
                        // NotifyUser(String.Format("The following text was read from '{0}' using a stream:{1}{2}", file.Name, Environment.NewLine, fileContent), NotifyType.StatusMessage);

                    }
                }
            }
            else
            {
                return (bool)false;
            }
        }
        catch
        {
            return (bool)false;
        }
c#
windows-phone-8
asked on Stack Overflow May 22, 2014 by GaneshGawali • edited May 22, 2014 by Ivaylo Slavov

1 Answer

0

You need to add the following permissions as described here:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
answered on Stack Overflow Apr 24, 2019 by Gonçalo Garrido • edited Apr 24, 2019 by Impulse The Fox

User contributions licensed under CC BY-SA 3.0