zoukankan      html  css  js  c++  java
  • 【万里征程——Windows App开发】如何在多个页面间读取/保存文件【草稿】

    首先在第二个页面中

    static public  StorageFolder  folder = Windows.Storage.ApplicationData.Current.LocalFolder;
    StorageFile file = await folder.CreateFileAsync("New Document.txt", CreationCollisionOption.ReplaceExisting);
    
    await FileIO.WriteTextAsync(file, "Write text to file4.");
    if (this.Frame != null)
    {
        this.Frame.Navigate(typeof(MainPage));
    }

    在主页面中:

     private async void LoadSettings()
            {
                StorageFile file = await AddProject.folder.GetFileAsync("New Document.txt");
                tBlockProjectName.Text = await FileIO.ReadTextAsync(file);
            }

    在主页面的MainPage中:

       LoadSettings();

    在主页面的OnNavigationTo中:

      protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                LoadSettings()
                // TODO: Prepare page for display here.
    
                // TODO: If your application contains multiple pages, ensure that you are
                // handling the hardware Back button by registering for the
                // Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
                // If you are using the NavigationHelper provided by some templates,
                // this event is handled for you.
            }

    版权声明:本文为 NoMasp柯于旺 原创文章,如需转载请联系本人。

  • 相关阅读:
    19.1.30 [LeetCode 24] Swap Nodes in Pairs
    19.1.29 [LeetCode 23] Merge k Sorted Lists
    06_Python异常处理机制
    05_Python的文件操作
    04_Python中的35个关键字
    03_Python基础语法
    02_Python开发环境使用和PDB调试
    01_Python基础知识梳理
    socket post
    python_socket_cmd
  • 原文地址:https://www.cnblogs.com/NoMasp/p/4785997.html
Copyright © 2011-2022 走看看