4

My program handles all the files specified by the user. After preferable to retain the modified file to the directory of the source file. StorageFolder.GetFolderFromPathAsync method returns "Access Denied".
File type associations in the manifest can not be added because after processing the files retain their extension. And what kind of file (with any extension), the user chooses to say impossible. The code in which an error occurs.

    internal async static void SetFile(List<byte> byteArray , StorageFile file)
    {
        try
        {
            string path = Path.GetDirectoryName(file.Path);
            StorageFolder newFolder = await StorageFolder.GetFolderFromPathAsync(path);
            StorageFile newFile = await newFolder.CreateFileAsync(string.Format(@"crt{0}", Path.GetFileName(file.Name)), CreationCollisionOption.FailIfExists);
            Stream stream = await file.OpenStreamForWriteAsync();
            BinaryWriter writer = new BinaryWriter(stream);
            writer.Write(byteArray);
            writer.Flush();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

StorageFile file - file that the user specified. I'm trying to create a new folder based on the path of the source file. An error - "Access Denied". To access this folder, i must register the file extensions that I use. It is impossible. Tell me, please, can we get around it as that? Or what can be done in my case?

  • From what I have understand : you have a file, do some manipulation with it and save it in the same location but with the name a little modified? – VasileF Aug 12 '13 at 18:58

1 Answers1

1

As far as I know, you cannot save a file in the PC unless you proceed with a saving Picker, in the case of a Windows Store App. That is why you might get Access Denied error. Click here for File Access and Permissions.

On the other hand, you can save files always, in a system location dedicated for the app itself, in the ApplicationData.LocalFolder .

You can set additional capabilites to your app so it could acces Removable Devices.

I don't know to be others than these.

VasileF
  • 2,856
  • 2
  • 23
  • 36
  • Explain, please, more. How often changes application's GUID? When you compile a new version or it depends on what is the other? Because of this change application folder. If data is lost, would be bad. – Daria Korosteleva Aug 14 '13 at 19:39
  • So far I have not try it, honestly, but some people told me that App data stored in LocalFolder would not be erased, if you make an update. – VasileF Aug 14 '13 at 22:35