WP7 上的 BinaryReader 和 Stream 性能

发布于 2024-11-07 00:35:44 字数 713 浏览 0 评论 0原文

问题...

如果您必须打开文件的 BinaryReader,是否有比打开资源流更高效的方法?

 System.IO.Stream myFileStream = Application.GetResourceStream(new Uri @"/MyApp;component/sdb.data", UriKind.Relative)).Stream;
 BinaryReader binaryReader = new BinaryReader(myFileStream);

其余的...

我正在为 WP7 应用程序使用 Sterling 数据库 (codeplex)。该应用程序需要在程序集中附带一个大型数据库。目前,我正在尝试使用 Sterling 执行 Restore() 从保存先前保存的文件 ( Backup() ) 创建数据库。目前,我正在获取备份文件并将其设置为应用程序中的“资源”,如上所示。 Sterling 数据库引擎需要 BinaryReader 通过 Restore() 加载数据。目前,恢复时间太长。我在 Sterling 讨论 中开始了一个讨论,但在 Stack 上发布在这里只是为了看看我是否可以比资源流做得更好。

The question...

If you must have a BinaryReader opend to a file, is there a more performant way to do it than opening a Stream to a Resource?

 System.IO.Stream myFileStream = Application.GetResourceStream(new Uri @"/MyApp;component/sdb.data", UriKind.Relative)).Stream;
 BinaryReader binaryReader = new BinaryReader(myFileStream);

All the rest...

I am using the Sterling Database (codeplex) for a WP7 app. The app is required to ship with a large db already inside the assembly. Currently, I am attempting a Restore() with Sterling to create a database from a file that holds a previously saved ( Backup() ). Currently, I am taking the backup file and setting it as a 'Resource' in the app, as shown above. The Sterling dtabase engine requires a BinaryReader to load the data via a Restore(). Currently, the restore just takes too long. I have a discussion started in the Sterling Discussions, but posted here on Stack just to see if I could do better than a stream to a resource.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半葬歌 2024-11-14 00:35:44

看起来好像您正在将数据库嵌入为资源 - 您是否尝试过将文件上的“构建操作”属性设置为“内容”,然后像这样加载它:

System.IO.Stream myFileStream = Application.GetResourceStream(new Uri(@"/component/sdb.data", UriKind.Relative)).Stream;

虽然我自己没有尝试过,但使用“内容”而不是“资源”显然具有性能对图像的影响,我认为对其他二进制文件的影响: http://www.windowsphonegeek.com/tips/wp7-working-with-images-content-vs-resource-build-action

It looks as though you are embedding your database as a resource - have you tried setting the Build Action property on the file to Content, and then loading it like this:

System.IO.Stream myFileStream = Application.GetResourceStream(new Uri(@"/component/sdb.data", UriKind.Relative)).Stream;

Although I've not tried it myself, using Content over Resource apparently has performance implications for images, and I assume, for other binary files: http://www.windowsphonegeek.com/tips/wp7-working-with-images-content-vs-resource-build-action

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文