locked
StorageFile.GetFileFromPathAsync copying files from a network - Does not work !!

    Question

  • Hello

    I am writing a Line of Business app for windows 8 and part of the process is a background task that will copy image files from a central UNC path to the local documents dir in order that they can be displayed in a loop on a page..

    I have read the document below that would indicate that this is possible but I keep getting access denied errors.

    http://msdn.microsoft.com/en-us/library/windows/apps/hh967755.aspx

    I am testing the std File Access Sample and have changed one line of code in the constants.cs

    I have turned on EVERY Capability and added the file ext and set file open / picker as allowed

    The unc is read write for everyone and is on the same machine

    Has anyone Ever got this to work ??

     private async void Initialize()

            {
                try
                {
                    //sampleFile = await Windows.Storage.KnownFolders.DocumentsLibrary.GetFileAsync(filename);
                    string myfile = @"\\ALL387\Temp\testfile.txt";
                    sampleFile = await Windows.Storage.StorageFile.GetFileFromPathAsync(myfile);

                }
                catch (FileNotFoundException)
                {
                    // sample file doesn't exist so scenario one must be run
                }

                catch (Exception e)
                {
                    var fred = e.Message;

                }

    I am also considering converting the inc share to a web site, would this work ? Does anyone have a sample for reading all files returned from a call to a browsable web folder ?

    TIA

    Sunday, March 03, 2013 8:29 PM

Answers

  • Hi,

    I finally got this to work.

    It seems that you cannot open the files on the remote unc path despite all the settings.

    I ended up doing a copy of the files to a localknown dir and opening them there

    one other point to note... I did this with a background maint task but despite what the tutorials say the ony way that would work was to place the entire copy function and code into a separate win RT component project..

    Thanks

    B...

    Tuesday, March 05, 2013 1:10 AM

All replies

  • Did you do this step?

    Note  You must add File Type Associations to your app manifest that declare specific file types that your app can access in this location.

    -Jeff


    Jeff Sanders (MSFT)

    Monday, March 04, 2013 6:05 PM
    Moderator
  • Hi,

    I finally got this to work.

    It seems that you cannot open the files on the remote unc path despite all the settings.

    I ended up doing a copy of the files to a localknown dir and opening them there

    one other point to note... I did this with a background maint task but despite what the tutorials say the ony way that would work was to place the entire copy function and code into a separate win RT component project..

    Thanks

    B...

    Tuesday, March 05, 2013 1:10 AM