【发布时间】:2011-12-03 16:41:36
【问题描述】:
使用相对 uri 路径在 WP7 中显示任何图像非常简单。 但是加载一个文本文件就成了一个大问号。
请查看图片,并尝试帮助将文件作为字符串变量的 URI 看起来如何。
Dim S As String
Dim U As New Uri("file:///Family_christmas;component/database/de/1.txt", UriKind.Absolute)
Dim sr As New IO.StreamReader(U.LocalPath, System.Text.Encoding.Unicode)
S = sr.ReadToEnd
sr.Close()
Me.Title = S.Split(Environment.NewLine)(0)
Me.Text = S.Substring(Me.Title.Length + Environment.NewLine.Length)
* 以这种方式解决了 *
将文件声明为资源而不是内容。然后使用以下代码:
Dim S As String
Dim U As New Uri("database/de/1.txt", UriKind.Relative)
Dim streamInfo As Windows.Resources.StreamResourceInfo = Application.GetResourceStream(U)
Dim sr As New IO.StreamReader(streamInfo.Stream, System.Text.Encoding.Unicode)
S = sr.ReadToEnd
sr.Close()
【问题讨论】:
标签: .net windows-phone-7 path uri