How to zip a database file in winrt app?


  • I have a sqlite database file "test.db". I want to zip this file through c# code. But when I am trying to do this, I am getting "Access is denied" exception.

    Here is the code that I am using :
    byte[] buffer = WindowsRuntimeBufferExtensions.ToArray(await FileIO.ReadBufferAsync(fileToCompress));
    ZipArchiveEntry entry = zipArchive.CreateEntry(fileToCompress.Name);
    using (Stream entryStream = entry.Open())
        await entryStream.WriteAsync(buffer, 0, buffer.Length);

    Can any one tell how I can zip a database file in winrt app through c# code ?

    Thursday, May 01, 2014 8:52 AM

All replies

  • Is the db file in use when you're trying to zip it?  Do other files also fail?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, May 01, 2014 7:38 PM