Windows phone 8 WP8-如何逐行读取文本文件?

Windows phone 8 WP8-如何逐行读取文本文件?,windows-phone-8,readline,Windows Phone 8,Readline,基本上,我只是在玩提供的保护数据示例,以及如何加密文本文件等等。我设法做了一些修改,这就是我目前所做的: 下面是我的XAML <Grid x:Name="LayoutRoot" Background="Transparent"> <!--TitlePanel contains the name of the application and page title--> <StackPanel x:Name="TitlePanel" Grid.Row

基本上,我只是在玩提供的保护数据示例,以及如何加密文本文件等等。我设法做了一些修改,这就是我目前所做的: 下面是我的XAML

<Grid x:Name="LayoutRoot" Background="Transparent">


    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="Secure DATA" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="Encrypt" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Margin="12,0,12,0" Height="768" VerticalAlignment="Top">


        <TextBlock Margin="10,333,22,405" >
            <Run Text="Enter your "/>
            <Run Text="ACCOUNT PASSWORD:"/>
        </TextBlock>
        <TextBox x:Name="TBPin" Height="75" Width="444" HorizontalAlignment="Left" Margin="0,355,0,338" InputScope="Number" />
        <Button x:Name="BtnStore" Content="Save" Click="BtnStore_Click" Margin="0,585,222,103" FontSize="21.333" FontFamily="Segoe WP SemiLight" RenderTransformOrigin="0.495,0.481" />
        <Button x:Name="BtnRetrieve" Content="Load" Click="BtnRetrieve_Click" Margin="221,585,12,103" FontSize="21.333" FontFamily="Segoe WP SemiLight" />
        <TextBlock Margin="10,157,22,580" >
            <Run Text="Enter your "/>
            <Run Text="ACCOUNT NAME"/>
            <Run Text=":"/>
        </TextBlock>
        <TextBox x:Name="AccName" Width="444" HorizontalAlignment="Left" Margin="0,177,0,516" Height="75" InputScope="Chat" Text="LoL" />
        <TextBlock Margin="10,244,22,494" >
            <Run Text="Enter your "/>
            <Run Text="ACCOUNT USERNAME:"/>
        </TextBlock>
        <TextBox x:Name="AccUser" Height="75" Width="444" HorizontalAlignment="Left" Margin="0,266,0,427" />
        <TextBlock Margin="10,423,22,315" Text="Notes about this account:" />
        <TextBox x:Name="AccNotes" Width="444" HorizontalAlignment="Left" Margin="0,445,0,170" InputScope="Chat" />
    </Grid>
</Grid>
所以,我点击store,它就会存储,当我想加载时,我只需键入保存信息的名称,它就会加载我遇到的问题是,一旦单击“加载”,它就会将该文本文件中的所有内容加载到其他文本框中。这张图片将更好地说明我的观点:

正如您所看到的,它在一个文本框中为每个文本框加载所有内容我想做的是,例如,对于用户名文本框,我只想显示第一行,密码文本框,我只想显示该文本文件的第三行。我如何实现这一点

如果可能的话,VB代码会很好,但C也可以。我可以转换一下


谢谢

获得字符串后,只需使用
Split
检索每一行,然后将它们分配给所需的文本框。在C#中,它将是:

var PinByte = ProtectedData.Unprotect(ProtectedPinByte, null);
var content = Encoding.UTF8.GetString(PinByte, 0, PinByte.Length);
var lines = content.Split('\n');

AccName.Text = lines[0]; // Take the first line
TBPin.Text = lines[2]; // Take the third line
// and so on
我的VB生锈了,但我相信它会是这样的:

Dim ProtectedPinByte As Byte() = Me.ReadPinFromFile()
Dim PinByte As Byte() = ProtectedData.Unprotect(ProtectedPinByte, Nothing)
Dim content As String = Encoding.UTF8.GetString(PinByte, 0, PinByte.Length)
Dim lines As String() = content.Split(vbLf)

AccName.Text = lines(0)
TBPin.Text = lines(2)

获得字符串后,只需使用
Split
检索每一行,然后将它们分配给所需的文本框。在C#中,它将是:

var PinByte = ProtectedData.Unprotect(ProtectedPinByte, null);
var content = Encoding.UTF8.GetString(PinByte, 0, PinByte.Length);
var lines = content.Split('\n');

AccName.Text = lines[0]; // Take the first line
TBPin.Text = lines[2]; // Take the third line
// and so on
我的VB生锈了,但我相信它会是这样的:

Dim ProtectedPinByte As Byte() = Me.ReadPinFromFile()
Dim PinByte As Byte() = ProtectedData.Unprotect(ProtectedPinByte, Nothing)
Dim content As String = Encoding.UTF8.GetString(PinByte, 0, PinByte.Length)
Dim lines As String() = content.Split(vbLf)

AccName.Text = lines(0)
TBPin.Text = lines(2)

获得字符串后,只需使用
Split
检索每一行,然后将它们分配给所需的文本框。在C#中,它将是:

var PinByte = ProtectedData.Unprotect(ProtectedPinByte, null);
var content = Encoding.UTF8.GetString(PinByte, 0, PinByte.Length);
var lines = content.Split('\n');

AccName.Text = lines[0]; // Take the first line
TBPin.Text = lines[2]; // Take the third line
// and so on
我的VB生锈了,但我相信它会是这样的:

Dim ProtectedPinByte As Byte() = Me.ReadPinFromFile()
Dim PinByte As Byte() = ProtectedData.Unprotect(ProtectedPinByte, Nothing)
Dim content As String = Encoding.UTF8.GetString(PinByte, 0, PinByte.Length)
Dim lines As String() = content.Split(vbLf)

AccName.Text = lines(0)
TBPin.Text = lines(2)

获得字符串后,只需使用
Split
检索每一行,然后将它们分配给所需的文本框。在C#中,它将是:

var PinByte = ProtectedData.Unprotect(ProtectedPinByte, null);
var content = Encoding.UTF8.GetString(PinByte, 0, PinByte.Length);
var lines = content.Split('\n');

AccName.Text = lines[0]; // Take the first line
TBPin.Text = lines[2]; // Take the third line
// and so on
我的VB生锈了,但我相信它会是这样的:

Dim ProtectedPinByte As Byte() = Me.ReadPinFromFile()
Dim PinByte As Byte() = ProtectedData.Unprotect(ProtectedPinByte, Nothing)
Dim content As String = Encoding.UTF8.GetString(PinByte, 0, PinByte.Length)
Dim lines As String() = content.Split(vbLf)

AccName.Text = lines(0)
TBPin.Text = lines(2)

嘿非常感谢,我很快就要试一试,我会让你知道:)嘿!非常感谢,我很快就要试一试,我会让你知道:)嘿!非常感谢,我很快就要试一试,我会让你知道:)嘿!非常感谢,我很快就要试一试,我会让你知道:)