Hi guys, sometimes happens that you have to open an XML file that is oversized and your editor won’t open it in anyway.

With the following simple .NET code you can split evry kind of XML file in a number of files matching with the number of nodes elemnts of your oversized file, here is the method:


[code language=”csharp”]

public static void FileXmlSplit(string fileToSplit, string destinationFolder)
string path = Path.GetFullPath(destinationFolder);
string filename = Path.GetFileName(fileToSplit);
if (!string.IsNullOrEmpty(fileToSplit) && !string.IsNullOrEmpty(destinationFolder))
.Select((e, i) => new { Element = e, File = ++i + “.xml” })
.ToList().ForEach(x => x.Element.Save(path + filename + x.File));


You will simply set the file to split and the destination folder for all your splitted files and include using System.Xml.Linq.
Click the button below to download the Visual Studio Project.