VS05自带打包功能(virusplayer )

levenwood levenwood 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这两天,照着网上弄了个网站打包的小程序:连接数据库,指定虚拟目录
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
Form1 fr = new Form1();
if (fr.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
try
{
XmlDocument xmldocument = new XmlDocument();
xmldocument.Load(Path.Combine(getpath(), "Web.config"));

//'查找到appsettings中的节点

//XmlNode node=new XmlNode();

bool FoundIt = false;
XmlNodeList nodes = xmldocument.SelectSingleNode("/configuration/connectionStrings").ChildNodes;
foreach (XmlNode node in nodes)
{
if (node.Name == "add")
{
if (node.Attributes["name"].Value == "myconnString")
{
//'写入连接字符串
node.Attributes["connectionString"].Value = String.Format("Data Source={0};User ID={1};pwd={2};Initial Catalog={3}",
fr.DbServer, fr.LoginName, fr.Password, fr.Db);
FoundIt = true;
xmldocument.Save(Path.Combine(getpath(), "Web.config"));
}
}
}

if (!FoundIt)
{
throw new ApplicationException("Web.Config 文件没有包含connectionString连接字符串设置");
}
else
{
CreateVirtualDir(fr.SiteName, this.Context.Parameters[""]);
}

}
catch (Exception ex)
{
throw ex;
}
}
else
{
throw new ApplicationException("应用程序数据库安装失败");
}
}

也增加了自定义操作,可安装过程中自己写的窗口并没有弹出来,不知道是什么原因,向大家请教,也希望virusplayer来看看
...全文
评论 26
收藏 已收藏
分享
返回顶部
levenwood
.NET社区 62,273 成员 668,968 内容