I just tried to upgrade my project to .net8 and Graphviz.NetWrapper 2.0.0. After making a few smaller changes to make my code compatible with the new version, I still ran into some issues when trying to save my Graph as a SVG or PNG. I then tried a small proof of concept app, and noticed that I only get an error if my folder path contains a space.
using Rubjerg.Graphviz;
class Program
{
static void Main(string[] args)
{
RootGraph root = RootGraph.CreateNew(GraphType.Directed, "Some Unique Identifier");
Node nodeA = root.GetOrAddNode("A");
Node nodeB = root.GetOrAddNode("B");
Node nodeC = root.GetOrAddNode("C");
Edge edgeAB = root.GetOrAddEdge(nodeA, nodeB, "Some edge name");
Edge edgeBC = root.GetOrAddEdge(nodeB, nodeC, "Some edge name");
Edge anotherEdgeBC = root.GetOrAddEdge(nodeB, nodeC, "Another edge name");
Edge edgeAB1 = root.GetOrAddEdge(nodeA, nodeB);
Edge edgeAB2 = root.GetOrAddEdge(nodeA, nodeB);
Node.IntroduceAttribute(root, "my attribute", "defaultvalue");
nodeA.SetAttribute("my attribute", "othervalue");
Edge.IntroduceAttribute(root, "my attribute", "defaultvalue");
edgeAB.SetAttribute("my attribute", "othervalue");
edgeBC.SafeSetAttribute("arrowsize", "2.0", "1.0");
edgeBC.SetAttribute("new attr", "value");
Node.IntroduceAttribute(root, "label", "defaultlabel");
nodeB.SetAttributeHtml("label", "<b>Some HTML string</b>");
// We can simply export this graph to a text file in dot format
root.ToDotFile(@"c:/tmp/Test Folder/out.dot");
RootGraph root2 = RootGraph.FromDotFile("c:/tmp/Test Folder/out.dot");
//the following 2 lines fail
root2.ToSvgFile("c:/tmp/Test Folder/dot_out.svg");
root2.ToPngFile("c:/tmp/Test Folder/dot_out.png");
}
}
If I change it to "c:/tmp/TestFolder/dot_out.svg" it works.