locked
Removing the hidden file attribute from a file in my local storage

    Question

  • I have this mechanism in my app that users can "paste" files from the desktop to my app. When they do, I copy the files into my apps local folder.

    However, the user can also copy files in Explorer that are "hidden" if he has them visible. Unfortunately I cannot access hidden files even in my local folder. Why this limitation? It makes no sense at all.

    To overcome this issue I tried to remove the hidden attribute. But somehow this is also not possible.

    setFileAttributesAsync = function(file, attributes) {
        return file.properties.retrievePropertiesAsync(["System.FileAttributes"]).then(function(properties) {
          properties["System.FileAttributes"] = attributes;
          return file.properties.savePropertiesAsync(properties);
        });
      };

    This will successfully set a file read-only but never remove the "hidden" or "archive" attribute when called like this:

    sourceFile.copyAsync(blobFolder, blobFilename, NameCollisionOption.failIfExists).then(function(destFile) {
              return setFileAttributesAsync(destFile, Windows.Storage.FileAttributes.readOnly);
    }

    What am I doing wrong? Or is this simply not possible, by obscure "security" design?

    Tuesday, February 19, 2013 12:34 PM

All replies

  • Hi,

    Please change the code as follow as follow and have a try:

    sourceFile.copyAsync(blobFolder, blobFilename, NameCollisionOption.failIfExists).then(function(destFile) {
              return setFileAttributesAsync(destFile, Windows.Storage.FileAttributes.normal);
    }


    Roy
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 20, 2013 6:48 AM