public void WriteNewSlnFile(Sln slnObject) { _sln = slnObject; _slnFile = new SlnFile(); // or you can read sln file like below using (SolutionFileReader reader = new SolutionFileReader(_sln.ObjectFullPath)) _slnFile = reader.ReadSolutionFile(); AddHeaders(); AddGlobalSections(); // add projects List <SolutionNode> sns = _sln.GetAllSubItemsOf(typeof(SolutionFolder), typeof(ProjectNode)); foreach (SolutionNode sn in sns) { _slnFile.Projects.Add(CreateProject(sn)); } using (SolutionFileWriter writer = new SolutionFileWriter(_sln.ObjectFullPath)) writer.WriteSolutionFile(_slnFile); }