WP7 上的 BinaryReader 和 Stream 性能
问题...
如果您必须打开文件的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来好像您正在将数据库嵌入为资源 - 您是否尝试过将文件上的“构建操作”属性设置为“内容”,然后像这样加载它:
虽然我自己没有尝试过,但使用“内容”而不是“资源”显然具有性能对图像的影响,我认为对其他二进制文件的影响: 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:
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