如何给wpf程序启动需要参数如何设置

如何给wpf程序启动需要参数如何设置,第1张

右键点击你的项目--选择保持默认名称,否则你的程序读取App.config时得到的值是空的。

2

打开App.config,添加应用程序设置的5个键值

first_run: 应用程序第一次正常启动

server: 服务器IP

database: 数据库名称

uid: 数据库用户名

pwd: 数据库密码

数据库服务器配置在程序首次启动时的值都是空的

3

右键点击项目中的应用,添加一个引用,然后再你需要访问配置文件的类顶部添加 using

<Title Row="0" Cloumn="2" Contenttitle="aaa" Assemblydll="aaa.dll" InterFace="aaaaaa" ImageUrl="pack://application:,,,/TyPlatformcomponent/Images/111.png" Width="180" Height="180" ></Title>

就像这样的一个XML,读成DataSet,然后这样取值

DataTable dt

DataSet ds = new DataSet()

ds.ReadXml(Environment.CurrentDirectory + "/" + path)

dt = ds.Tables[0]

string Row = dt.Rows[index]["Row"].ToString()

string Cloumn = dt.Rows[index]["Cloumn"].ToString()

string Height = dt.Rows[index]["Height"].ToString()

string Width = dt.Rows[index]["Width"].ToString()

string ImageUrl = dt.Rows[index]["ImageUrl"].ToString()


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11343749.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-15
下一篇 2023-05-15

发表评论

登录后才能评论

评论列表(0条)

保存