Hi
Hopefully someone can help me with this?
A Colleague gave me a snippet of C# code to try (and prove) in Visual Cron .NET (see below). It compiles absolutely fine but it doesn't find any methods when I try to 'Save' it (it says .Missing Value 'Method'). Anybody know what's wrong with this code when they say it works correctly in Visual Studio?
============================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Linq;
namespace XmlMergeSort
{
class XmlOperationNew
{
public void XmlMerge(string sourceFolder, string destinationFolder)
{
StringBuilder strBldr = null;
try
{
if (sourceFolder != string.Empty)
{
if (Directory.Exists(sourceFolder))
{
var files = System.IO.Directory.GetFiles(sourceFolder, "*.xml");
XmlDocument xDoc = new XmlDocument();
if (files.Length > 0)
{
strBldr = new StringBuilder();
strBldr.AppendLine(@"<?xml version=""1.0"" encoding=""UTF-8"" ?>");
strBldr.AppendLine("<Root>");
foreach (string file in files)
{
try
{
xDoc = new XmlDocument();
strBldr.AppendLine("<" + Path.GetFileNameWithoutExtension(file) + ">");
xDoc.LoadXml(File.ReadAllText(file));
strBldr.AppendLine(xDoc.DocumentElement.OuterXml);
strBldr.AppendLine("</" + Path.GetFileNameWithoutExtension(file) + ">");
}
catch (Exception ex)
{
continue;
}
}
strBldr.AppendLine("</Root>");
if (destinationFolder != string.Empty)
{
if (Directory.Exists(destinationFolder))
{
File.WriteAllText(Path.Combine(destinationFolder, "TestOutput.xml"), strBldr.ToString());
}
}
else
{
File.WriteAllText(Path.Combine(destinationFolder, "TestOutput.xml"), strBldr.ToString());
}
}
}
}
}
catch (Exception ex)
{
// Write code for logging error
}
}
}
}
===========================================
Thanks in advance
Andy
Edited by moderator
2014-09-05T10:39:32Z
|
Reason: Not specified