Exemplo n.º 1
0
        private async void cbbList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string name = (cbbList.SelectedItem as Datac).name;

            var           local  = Windows.Storage.ApplicationData.Current.LocalFolder;
            StorageFolder folder = await local.GetFolderAsync("Data");

            IReadOnlyList <StorageFile> files = await folder.GetFilesAsync();

            foreach (StorageFile item in files)
            {
                if (item.Name.Equals(name))
                {
                    var file = await folder.GetFileAsync(item.Name);

                    string lines = await FileIO.ReadTextAsync(file);

                    Datac data = new Datac()
                    {
                        content = lines
                    };
                    txtContentv.DataContext = data;
                }
            }
        }
Exemplo n.º 2
0
        public async void abc()
        {
            var           local  = Windows.Storage.ApplicationData.Current.LocalFolder;
            StorageFolder folder = await local.GetFolderAsync("Data");

            IReadOnlyList <StorageFile> files = await folder.GetFilesAsync();

            foreach (StorageFile item in files)
            {
                Datac data = new Datac();
                data.name = item.Name;
                lstdata.Add(data);
            }
            cbbList.ItemsSource = lstdata;
        }
Exemplo n.º 3
0
        private async void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text.Length != 0 &&
                txtContent.Text.Length != 0
                )
            {
                Datac user = new Datac();
                user.name    = txtName.Text;
                user.content = txtContent.Text;


                var local = Windows.Storage.ApplicationData.Current.LocalFolder;
                var file  = await local.CreateFileAsync(@"\Data\" + txtName.Text, Windows.Storage.CreationCollisionOption.OpenIfExists);

                await FileIO.AppendTextAsync(file, user.ToString());


                MessageDialog msg = new MessageDialog("Write Data Success");
                await msg.ShowAsync();
            }
        }