打开 Resource.resx 文件而不是创建它,这会覆盖以前的 Resource.resx 文件

发布于 2024-11-15 06:42:16 字数 989 浏览 7 评论 0原文

我从 Visual Studio 2010 中启动我的应用程序。 然后我将一些文件添加到我的应用程序中,并且每个文件类型的图标(例如 doc、docx、xls、pdf 等中的图标)作为字符串/位图键/值对添加到我的 IconImages.Resx 文件中,通过

private void DumpTempResourceToRealResourceFile(IDictionary<String, Bitmap> tempResource)
        {

            using (ResXResourceWriter writer = new ResXResourceWriter("IconImages.Resx"))
            {
                foreach (KeyValuePair<String,Bitmap> item in tempResource)
                {
                    writer.AddResource(item.Key, item.Value);                    
                }
                writer.Generate();
            }            
        }

将图标添加到资源 我关闭应用程序。

然后我使用 VS 2010 再次启动我的应用程序,并在我的文档应用程序中添加一些文件。文件类型再次写入我的 IconImages.Resx。 然后我关闭我的应用程序并检查 \bin\ 文件夹下的 IconImages.Resx 文件,以前保存的图像已经消失,现在有新的/不同的图像。

为什么我不能说“打开 .resx 文件并向其中添加内容”?每次我创建一个具有相同名称“IconImages.Resx”的 ResourceWriter 对象时,我都会覆盖之前添加的内容,这很愚蠢。

我的 IconImages.Resx 文件如何在应用程序会话中保持活动状态,而不被我添加的其他内容覆盖?

I start my application from withint Visual Studio 2010.
I add then some files into my application and each file type`s icon like icon from doc,docx,xls,pdf etc are added as String/Bitmap key/value pair to my IconImages.Resx file via

private void DumpTempResourceToRealResourceFile(IDictionary<String, Bitmap> tempResource)
        {

            using (ResXResourceWriter writer = new ResXResourceWriter("IconImages.Resx"))
            {
                foreach (KeyValuePair<String,Bitmap> item in tempResource)
                {
                    writer.AddResource(item.Key, item.Value);                    
                }
                writer.Generate();
            }            
        }

When the icons are added to the resource I close the application.

Then I start my application again with VS 2010 and add some files within my document application. The file types are written again to my IconImages.Resx.
Then I close my application and check the IconImages.Resx file under the \bin\ folder and the previous saved images are gone and I have new/different ones now.

Why can I not say OPEN a .resx file and append stuff to it? Everytime I create a ResourceWriter object with the same name "IconImages.Resx" I overwrite the previous added stuff and thats stupid.

How can my IconImages.Resx file stay alive over an application session without being overwritten by other stuff I add?

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

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

发布评论

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

评论(2

离线来电— 2024-11-22 06:42:16

我没有使用过 ResXResourceWriter,但通常 *Writer 类只是从头开始写入数据文件。

如果您想“追加”新数据,通常必须使用 *Reader 类将现有数据反序列化到内存中,然后合并/添加您想要的任何新数据,并使用 *Writer 对象写入结果数据退出。查看 ResXResourceReader 看看它是否支持您执行此操作所需的功能。

I haven't used ResXResourceWriter, but usually *Writer classes simply write a data file from scratch.

If you want to "append" new data you would typically have to use a *Reader class to deserialise the existing data into memory, then merge/add in any new data you wish to, and use a *Writer object to then write the resulting data back out. Take a look at ResXResourceReader to see if it supports what you need to do this.

多情出卖 2024-11-22 06:42:16

我现在有一个查找表“FiletypeImage”,其中包含文件类型“.docx”和原始二进制数据(又名 blob)。该表在我的 documentService 中检索并缓存在静态变量中。使用我的 DocumentListViewModel 调用的 Get 和 Add 方法。它非常快,谢谢 sqlite :)

I am having now a lookup table "FiletypeImage" with the filetype ".docx" and the raw binary data aka blob. This table gets retrieved in my documentService and cached in a static variable. with a Get and Add method which are called by my DocumentListViewModel. Its very fast thx to sqlite :)

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