Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


osirisja
2014-09-03T17:21:11Z
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
Sponsor
Forum information
Support
2014-09-03T18:49:48Z
Try creating the method static. Only those are found.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2014-09-03T18:50:20Z
public static void XmlMerge(string sourceFolder, string destinationFolder)
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
osirisja
2014-09-05T08:56:47Z
Thanks Henrik - that fixed it

Cheers

Andy
Scroll to Top