问题描述
受保护的无效test_Click(对象发送者,EventArgs e)
{
XmlDocument Reportxml =新的XmlDocument();
试试
{
//指定要操作的目录.
字符串路径= Server.MapPath("Store/Reports");
试试
{
//确定目录是否存在.
如果(!Directory.Exists(path))
{
//尝试创建目录.
DirectoryInfo di = Directory.CreateDirectory(path);
}
}
catch(ex ex例外)
{
ScriptManager.RegisterStartupScript(Page,typeof(Page),
"ShowAlert",
string.Format(@"
函数_showAlert(){{Sys.Application.remove_load(_showAlert);
radalert(''{0}'',null,100,``{1}'');}};
Sys.Application.add_load(_showAlert);,"创建报告目录时发生错误.</br>原因:"+例如消息," BMS Forecast Consolidator),true);
}
字符串文本= Server.MapPath("Store/Reports/PublishedReport.xml");
字符串text2 = Server.MapPath("Store/Reports/PublishedReport2.xml");
{
Reportxml.Load(text);
XmlNodeList元素= Reportxml.SelectNodes("//OlapReports/OlapReport");
var currentnode = ocGeneric.OlapManager.CurrentOlapReport.Name;
foreach(元素中的XmlElement元素)
{
字符串ReportName = element.GetAttribute("Name");
//int RptName = Int32.Parse(element.GetAttribute("Name"));
字符串xPathExpression ="/OlapReports/OlapReport [@ Name =''" + ReportName +'']";
XmlElement SingleRptNode =(XmlElement)Reportxml.SelectSingleNode(xPathExpression);
字符串displar = xPathExpression.Trim().Clone().ToString();
//ReportName.Clone().ToString();
//Reportxml.Save("PublishedReport2");
Reportxml.Save("Store/Reports/PublishedReport2.xml");
}
}
ocGeneric.OlapManager.SaveReports(Server.MapPath("Store/Reports/PublishedReport2.xml"));
}
catch(ex ex例外)
{
ScriptManager.RegisterStartupScript(Page,typeof(Page),
"ShowAlert",
string.Format(@"
函数_showAlert(){{Sys.Application.remove_load(_showAlert);
radalert(''{0}'',null,100,``{1}'');}};
Sys.Application.add_load(_showAlert);,"发布报告时发生错误.</br>原因:"+ ex.Message," test),true);
}
}
protected void test_Click(object sender, EventArgs e)
{
XmlDocument Reportxml = new XmlDocument();
try
{
// Specify the directory you want to manipulate.
string path = Server.MapPath("Store/Reports");
try
{
// Determine whether the directory exists.
if (!Directory.Exists(path))
{
// Try to create the directory.
DirectoryInfo di = Directory.CreateDirectory(path);
}
}
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(Page, typeof(Page),
"ShowAlert",
string.Format(@"
function _showAlert() {{Sys.Application.remove_load(_showAlert);
radalert(''{0}'', null, 100, ''{1}'');}};
Sys.Application.add_load(_showAlert);", "Error occured while creating Reports directory.</br>Reason: " + ex.Message, "BMS Forecast Consolidator"), true);
}
string text = Server.MapPath("Store/Reports/PublishedReport.xml");
string text2 = Server.MapPath("Store/Reports/PublishedReport2.xml");
{
Reportxml.Load(text);
XmlNodeList elements = Reportxml.SelectNodes("//OlapReports/OlapReport");
var currentnode = ocGeneric.OlapManager.CurrentOlapReport.Name;
foreach (XmlElement element in elements)
{
string ReportName = element.GetAttribute("Name");
// int RptName = Int32.Parse(element.GetAttribute("Name"));
string xPathExpression = "/OlapReports/OlapReport[@Name='' " + ReportName + "'']";
XmlElement SingleRptNode = (XmlElement)Reportxml.SelectSingleNode(xPathExpression);
string displar = xPathExpression.Trim().Clone().ToString();
// ReportName.Clone().ToString();
// Reportxml.Save("PublishedReport2");
Reportxml.Save("Store/Reports/PublishedReport2.xml");
}
}
ocGeneric.OlapManager.SaveReports(Server.MapPath("Store/Reports/PublishedReport2.xml"));
}
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(Page, typeof(Page),
"ShowAlert",
string.Format(@"
function _showAlert() {{Sys.Application.remove_load(_showAlert);
radalert(''{0}'', null, 100, ''{1}'');}};
Sys.Application.add_load(_showAlert);", "Error occured while publising report.</br>Reason: " + ex.Message, "test"), true);
}
}
推荐答案
这篇关于如何查找特定的select xml节点,以及如何通过指定文件路径将该节点另存为另一个xml文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!