【问题标题】:Emulator memory access WP7模拟器内存​​访问WP7
【发布时间】:2011-12-17 08:39:52
【问题描述】:

我下载了一个文件并将其保存在隔离存储中。我想知道我是否有办法在模拟器的内存中查看该文件。有什么办法吗?

【问题讨论】:

    标签: visual-studio windows-phone-7 emulation


    【解决方案1】:

    从 IO 的角度来看,Emulator 中的隔离存储就像真实设备上的隔离存储。例如,将一个文本文件保存到一个独立的存储调用中:

    IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
    
    //create new file
    using (StreamWriter writeFile = new StreamWriter(new IsolatedStorageFileStream("myFile.txt", FileMode.Create, FileAccess.Write, myIsolatedStorage)))
    {
        string someTextData = "This is some text data to be saved in a new text file in the IsolatedStorage!";
        writeFile.WriteLine(someTextData);
        writeFile.Close();
    }
    

    从独立存储中读取:

    IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
    IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile("myFile.txt", FileMode.Open, FileAccess.Read);
    using (StreamReader reader = new StreamReader(fileStream))
    {    //Visualize the text data in a TextBlock text
        this.text.Text = reader.ReadLine();
    }
    

    示例由windowsphonegeek提供

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多