C#编辑嵌入的资源,操作XML文件并保存

Helsing 2011-10-08 02:33:12
WinForm项目中有一个xml的配置文件,为了安全起见把它设置为嵌入的资源,读取它的信息完全没有问题,网上的资源也很多。但是做为配置文件,光读取还是不够的,我想编辑并保存它,这样问题就出现了。貌似嵌入的资源是只读的,无法编辑,网上也没找到相应的资源,只好向各位大侠求救了!
...全文
432 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Helsing 2011-10-10
  • 打赏
  • 举报
回复
我也知道加密能实现啊,我就是想着如果能修改嵌入的资源那该多好啊,省去很多麻烦。看来此路不通啊,也只能加密了。
sdl2005lyx 2011-10-09
  • 打赏
  • 举报
回复
用Configuration 类:
static void CreateSection()
{
try
{
CustomSection customSection;

System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);

if (config.Sections["CustomSection"] == null)
{
customSection = new CustomSection();
config.Sections.Add("CustomSection", customSection);
customSection.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);

Console.WriteLine("Section name: {0} created",
customSection.SectionInformation.Name);

}
}
catch (ConfigurationErrorsException err)
{
Console.WriteLine(err.ToString());
}

}
rinall 2011-10-08
  • 打赏
  • 举报
回复
加密吧。在正常使用中能更改的文件就只有配置文件和数据库。不可能每一个更改都自己去改dll文件。
feixuyue 2011-10-08
  • 打赏
  • 举报
回复
你都说了,还有什么拌饭么,
加密下吧;

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧