
var serializer = new CodeSnippetSerializer();
var path = Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location)!, "cw.snippet");
var streamReader = new StreamReader(path);
var snippets = serializer.LoadFromStream(streamReader.BaseStream);
serializer.SaveToFile(Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location)!, "cw1.snippet"), snippets.ToArray());
//The contents of the file "cw.snippet" and "cw1.snippet" are different
See my email for details.
cw.snippet
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>cw</Title>
<Shortcut>cw</Shortcut>
<Description>Console.WriteLine 的代码片段</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="false">
<ID>SystemConsole</ID>
<Function>SimpleTypeName(global::System.Console)</Function>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[$SystemConsole$.WriteLine($end$);]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
<Literal Editable="false">
<Literal IsEditable="False">
[Modified 3 years ago]