locked
Decompressing zip file RRS feed

  • Question

  • hi,

       I have created windows runtime component which is having code for unzipping zip files .

     public IAsyncOperationWithProgress<int, double> Uncompress(StorageFile File,StorageFolder Destination) 
            { 
                return AsyncInfo.Run<int, double>((Token, Progress) => 
                { 
                    return Task.Run(async () => 
                    { 
                        Progress.Report(0); 
                        await UnZipFile(File,Destination); 
                        Token.ThrowIfCancellationRequested(); 
                        Progress.Report(100.0); 
                        return 0; 
                    }, Token 
                      ); 
     
                }); 
            }

     the storagefile and folder retrives the path using file picker.

    (StorageFile File,StorageFolder Destination)

    i dont want to use file picker i need given local path.then how could i use storagefile and folder.

    i just called the runtime component from javascript by using below codes its showing javascript type missmatching error

    var file = "D:\\testunzip.zip";
     var folder = "D:\\test"
    
    resultAsync = new CompressRT.UnCompresser();
        resultAsync.uncompress(file1, file2).then(
        
            function () {
               alert("completed")
            },
    
            function () {
               alert("error")
            },
            function () {
              alert("progress")
            }
        );

    let me suggest how to use local path on uncompress method

    Wednesday, December 11, 2013 6:47 AM

Answers

All replies

  • Your application doesn't have access to arbitrary locations in the file system (such as D:\\test). The only way to get access to such locations is to use the file and folder pickers (or equivalent user choice, such as being launched by the user with that file).

    --Rob

    Wednesday, December 11, 2013 7:14 AM
    Moderator
  • Hi rob,

       I dont want to use arbitary locations.temporary or localfolder is enough how to apply localfolder path to this function argument

    public IAsyncOperationWithProgress<int, double> Uncompress(StorageFile File,StorageFolder Destination) 
            { 
                return AsyncInfo.Run<int, double>((Token, Progress) => 
                { 
                    return Task.Run(async () => 
                    { 
                        Progress.Report(0); 
                        await UnZipFile(File,Destination); 
                        Token.ThrowIfCancellationRequested(); 
                        Progress.Report(100.0); 
                        return 0; 
                    }, Token 
                      ); 
     
                }); 
            }


    Wednesday, December 11, 2013 7:40 AM
  • You can get the LocalFolder's StorageFolder from ApplicationData.Current.LocalFolder . See Quickstart: Local application data

    --Rob

    Wednesday, December 11, 2013 7:53 AM
    Moderator