简体   繁体   English

如何从另一台计算机加载xml配置文件?

[英]How to load xml config file from another computer?

I have application c#, config file is xml file. 我有应用程序C#,配置文件是xml文件。 If same computer it working is fine but not security. 如果是同一台计算机,则可以正常工作,但不能保证安全。 In this case, everyone can see and read this config file. 在这种情况下,每个人都可以看到和读取此配置文件。

Can I load xml file from another computer? 我可以从另一台计算机加载xml文件吗?

XDocument doc = XDocument.Load(fileXml);
var cmds = doc.Root
              .Element("ListProfile")
              .Elements("Profile")
              .Where(b => b.Element("Id").Value == profile_id)
              .SelectMany(b => b.Element("Command").Elements())
              .Select(p => new
               {
                   Id = (int)p.Element("Id"),
                   Path = (string)p.Element("Path"),
                   Value = (string)p.Element("Value")
               });

Thanks. 谢谢。

Do you want to load your config when starting the application, or is it possible to load the config after the initial load is done. 您是要在启动应用程序时加载配置,还是可以在初始加载完成后加载配置。 In the latter case, you would be better of using a webservice. 在后一种情况下,最好使用Web服务。

Also where is this second PC located? 第二台PC也位于哪里? Is it inside the same LAN or somewhere else? 是在同一局域网内还是在其他地方? Same as with the first point, the latter would make a webservice a better option. 与第一点相同,后者将使Web服务成为更好的选择。

Lastly, what is the security problem. 最后,什么是安全问题。 If you are worried about passwords in the config, you could encrypt these passwords, and load the encrypted password from the XML, then just decrypt and see if it's correct. 如果您担心配置中的密码,则可以对这些密码进行加密,然后从XML中加载加密的密码,然后解密并查看它是否正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM