locked
Access Denied in Pictures Library in windows 8 RRS feed

  • Question

  • Hai,

                I need to read files from Pictures Library.But iam receiving an Exception "Access Denied".Here is my code:

                 StorageFolder storageFolder = KnownFolders.PicturesLibrary;
                StorageFolder storage = await storageFolder.GetFolderAsync("InfoApp");
                StorageFile sampleFile = await storage.GetFileAsync("STF_CamdenCrawlIndex1.html");
    
                var stream = await sampleFile.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);            
                string text = await Windows.Storage.FileIO.ReadTextAsync(sampleFile); 

    string text = await Windows.Storage.FileIO.ReadTextAsync(sampleFile);

    Iam receiving Access is Denied error in this line.Can anyone pls tell me how to solve the issue?I have already given permission in Package.Manifest and given file type associations in Package.Manifest File.

     <Extensions>
            <Extension Category="windows.fileTypeAssociation">
              <FileTypeAssociation Name="xml">
                <EditFlags AlwaysUnsafe="true" />
                <SupportedFileTypes>
                  <FileType>.xml</FileType>
                </SupportedFileTypes>
              </FileTypeAssociation>
            </Extension>
            <Extension Category="windows.fileTypeAssociation">
              <FileTypeAssociation Name="png">
                <EditFlags AlwaysUnsafe="true" />
                <SupportedFileTypes>
                  <FileType>.png</FileType>
                </SupportedFileTypes>
              </FileTypeAssociation>
            </Extension>
            <Extension Category="windows.fileTypeAssociation">
              <FileTypeAssociation Name="jpg">
                <EditFlags AlwaysUnsafe="true" />
                <SupportedFileTypes>
                  <FileType>.jpg</FileType>
                </SupportedFileTypes>
              </FileTypeAssociation>
            </Extension>
            <Extension Category="windows.fileTypeAssociation">
              <FileTypeAssociation Name="html">
                <EditFlags AlwaysUnsafe="true" />            
                <SupportedFileTypes>
                  <FileType>.html</FileType>
                </SupportedFileTypes>
              </FileTypeAssociation>
            </Extension>
            <Extension Category="windows.fileTypeAssociation">
              <FileTypeAssociation Name="gif">
                <EditFlags AlwaysUnsafe="true" />
                <SupportedFileTypes>
                  <FileType>.gif</FileType>
                </SupportedFileTypes>
              </FileTypeAssociation>
            </Extension>
            <Extension Category="windows.search" />
          </Extensions>
    Pls help me to solve this issue.Thanks in Advance



    Wednesday, August 7, 2013 6:35 AM

Answers

  • Try to remove the line with the stream object - you're opening the file twice (stream & ReadText). That may be the problem.

    Life is unsure - always eat the dessert first!

    Wednesday, August 7, 2013 10:53 AM
  • Hello smanjula,

    can u check picturelibrary under capability in Package.appxmanifest file? Because if you can't check picture library that error ACCESS IS DENIED IS COME.

    Wednesday, August 7, 2013 11:22 AM

All replies

  • sounds like the file is locked by another (or your) process. What does the stream object look like? Is it actually there, or is it null?

    Life is unsure - always eat the dessert first!

    Wednesday, August 7, 2013 9:04 AM
  • Hai Michael,

             Thanks for u r rply.Stream object is not null.In that Particular line only iam getting this error.Can u pls tell me any solution for this?

    Wednesday, August 7, 2013 9:35 AM
  • Try to remove the line with the stream object - you're opening the file twice (stream & ReadText). That may be the problem.

    Life is unsure - always eat the dessert first!

    Wednesday, August 7, 2013 10:53 AM
  • Hello smanjula,

    can u check picturelibrary under capability in Package.appxmanifest file? Because if you can't check picture library that error ACCESS IS DENIED IS COME.

    Wednesday, August 7, 2013 11:22 AM