我有资源文件,它获得了文件的版本号。我想更新文件版本。我希望我的版本文件从5向上增加。
让我把它放在每个人都会理解的方式中。
所有这一切都与以下事实有关:每次点击新按钮我的版本重置并从5开始重新开始,我不希望它再次从五开始。我希望它继续继续或从最后创建的文件中携带。(就像在SQL上插入一样)5.6.7.8.9.10.11.12.13 .........
我已经检查了Fixed Assembly Version with Auto Incremented File Version?,但我对我的问题不太了解
每次创建新文件时如何输出文件版本?
资源文件
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>5</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
新按钮
private void btnNewfile_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(PathSelection);
XmlNode root = doc.DocumentElement;
XmlNode myNode = root.SelectSingleNode("descendant::resheader[@name = 'version']/value");
int iversion = Convert.ToInt32(myNode.InnerText);
iversion++;
lblversion.Text = iversion.ToString();
}
保存按钮
private void btnSave_Click(object sender, EventArgs e)
{
int iversion = Convert.ToInt32(lblversion.Text.ToString());
XmlDocument doc = new XmlDocument();
doc.Load(outputFilePath);
XmlNode root = doc.DocumentElement;
XmlNodeList CnodesList = root.SelectNodes("descendant::data");
XmlNode myNode = root.SelectSingleNode("descendant::resheader[@name = 'version']/value");
myNode.InnerText = iversion.ToString();
}
答案 0 :(得分:0)
当用户点击新文件时,您将使用版本加载源文件,将其增加1并保存源文件,保留新文件的版本。
答案 1 :(得分:0)
资源文件
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>5</value>
</resheader>
新按钮
private void btnNewfile_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(PathSelection);
XmlNode root = doc.DocumentElement;
XmlNode myNode = root.SelectSingleNode("descendant::resheader[@name = 'version']/value");
int iversion = Convert.ToInt32(myNode.InnerText);
iversion++;
lblversion.Text = iversion.ToString();
}
保存按钮
private void btnSave_Click(object sender, EventArgs e)
{
int iversion = Convert.ToInt32(lblversion.Text.ToString());
XmlDocument doc = new XmlDocument();
doc.Load(outputFilePath);
XmlNode root = doc.DocumentElement;
XmlNodeList CnodesList = root.SelectNodes("descendant::data");
XmlNode myNode = root.SelectSingleNode("descendant::resheader[@name = 'version']/value");
myNode.InnerText = iversion.ToString();
}