我如何从isolatedstoragefile中复制xml文件

时间:2014-06-17 11:47:54

标签: xml xaml c#-4.0 windows-phone-8 windows-phone

我正在处理isolatedstoragefile我需要从isolatedstoragefile复制xml文件,然后我需要读取xml文件。

我在行myIsolatedStorage.CopyFile();中收到错误,该行需要xml文件的路径,该文件位于我的公共文件夹中。设置路径后,它会抛出另一个异常

  

不允许

代码:

private async void CopyDatabase()
{
    bool isDatabaseExisting = false;

    try
    {
        StorageFolder InstallationFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Common");
        StorageFile file = await InstallationFolder.GetFileAsync("Notification.txt");
        IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();

        myIsolatedStorage.CopyFile("Notification.txt","Notification.txt",bool "abc.txt");

        IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
        isDatabaseExisting = true;
    }
    catch
    {
        isDatabaseExisting = false;
    }

    if (!isDatabaseExisting)
    {
        StorageFolder InstallationFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Common");
        StorageFile file = await InstallationFolder.GetFileAsync("Notification.xml");
        IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
        myIsolatedStorage.CopyFile(file.DisplayName, file.DisplayName);
    }
}

0 个答案:

没有答案