SWP/List/FileSystemSample/TextDisplay.xaml.cs

50 lines
1.4 KiB
C#
Raw Normal View History

2017-03-09 22:08:25 +01:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using FileSystemApi;
using StreamReader = System.IO.StreamReader;
namespace PhoneNetworkingSample
{
public partial class TextDisplay : PhoneApplicationPage
{
public string filePath;
public TextDisplay()
{
InitializeComponent();
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if(!NavigationContext.QueryString.TryGetValue("path", out filePath))
{
NavigationService.GoBack();
}
}
private void loadData(object sender, RoutedEventArgs e)
{
filePath = Uri.UnescapeDataString(filePath);
displayName.Text = filePath;
FileStream dataStr = File.Open(filePath, FileAccess.Read, FileShare.Read, CreationDisposition.OpenExisting);
StreamReader dataReader = new StreamReader(dataStr);
displayTxt.Text = dataReader.ReadToEnd();
}
}
}