如何保持文件夹/子文件夹在Combo或TreeView Box中的持久性? [英] How do I keep the folders/subfolders persistent in a Combo or TreeView Box?

查看:83
本文介绍了如何保持文件夹/子文件夹在Combo或TreeView Box中的持久性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何从组合框或树形视图控件中获取要保存的文件夹或文件.我的客户可以将文件拖放到组合框中(我也可以使用树形视图框),并且可以创建文件夹/子文件夹来存储这些文件.如何保存这些文件夹/子文件/文件,以便下次使用该软件开始时,控件充满了相同的文件夹/订阅/文件?我目前正在尝试序列化为xml,然后将其保存到SQL数据库表,然后在页面加载时调用该表.

I was wondering how I can get folders or files to be saved from a combo box or treeview control. My customer can drag and drop files into a combobox (I can use a treeview box also), and can create folders/subfolders to store those files in. How do I save those folders/subs/files so that the next time the software is started, the control is filled with those same folders/subs/files? I am presently trying serialize to xml, then save that to a SQL database table, then recall that table on page load. Is there an easier way to do this in C#/wpf/xaml?

推荐答案

如果您以XML序列化它,而没有数据库就足够了.如果这还不够好,则可以使用数据库,但不需要XML.

有关非常通用,简洁且易于使用的XML序列化,请查看数据协定:
http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ].

请在我倡导这种方法的地方查看我过去的答案:
如何在我的表单应用程序? [ ^ ],
创建属性文件... [反序列化json字符串数组 [ http://msdn.microsoft.com/en-us/library/ms750612% 28v = vs.100%29 [ ^ ],
http://msdn.microsoft.com/en-us/library/ms752057%28v = vs.100%29.aspx [ ^ ].

祝你好运,
—SA
If you serialize it in XML, it may be enough, without database. If this is not good enough, you can use the database, but don''t need XML.

For very universal, unobtrusive and easy-to-use XML serialization, please look at Data Contract:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

Please see my past answers where I advocate this approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^],
deseralize a json string array[^].

With databases, if you already know ADO.NET, I would advice to start with learning data binding:
http://msdn.microsoft.com/en-us/library/ms750612%28v=vs.100%29[^],
http://msdn.microsoft.com/en-us/library/ms752057%28v=vs.100%29.aspx[^].

Good luck,
—SA


这篇关于如何保持文件夹/子文件夹在Combo或TreeView Box中的持久性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆