this.xamSyntaxEditor1.Document.Load("C:\\file.txt");
In this topic, you will find instructions and code examples for using the xamSyntaxEditor™ TextDocument's Load and Save methods for loading and saving content.
The following topics are prerequisites to understanding this topic:
To complete the procedure, you need the following:
An instance of the xamSyntaxEditor
The xamSyntaxEditor’s Document property set to an instance of a TextDocument class.
This topic contains the following sections:
The following table lists the methods available to you for loading and saving TextD``ocument
content.
This method allows you to load a specific file by passing its location as a string value.
In C#:
this.xamSyntaxEditor1.Document.Load("C:\\file.txt");
In Visual Basic:
Me.xamSyntaxEditor1.Document.Load("C:\file.txt")
This method allows you to load document content from the stream you specify.
In C#:
FileInfo fi = new FileInfo("C:\\file.txt");
FileStream fs = fi.OpenRead();
this.xamSyntaxEditor1.Document.Load(fs);
In Visual Basic:
Dim fi As New FileInfo("C:\file.txt")
Dim fs As FileStream = fi.OpenRead()
Me.xamSyntaxEditor1.Document.Load(fs)
This method allows you to load a document’s content from a string value you specify.
In C#:
this.xamSyntaxEditor1.Document.InitializeText("the quick brown fox... ");
In Visual Basic:
Me.xamSyntaxEditor1.Document.InitializeText("the quick brown fox...")
This method allows you to save a document’s content to a specific file by passing its location as a string value.
Saves the document’s content to the file location, which you provide as string.
In C#:
this.xamSyntaxEditor1.Document.Save("C:\\file.txt");
In Visual Basic:
Me.xamSyntaxEditor1.Document.Save("C:\file.txt")
This method allows you to save a document to the stream you specify.
In C#:
FileInfo fi = new FileInfo("C:\\file.txt");
FileStream fs = fi.OpenWrite();
this.xamSyntaxEditor1.Document.Save(fs);
In Visual Basic:
Dim fi As New FileInfo("C:\file.txt")
Dim fs As FileStream = fi.OpenWrite()
Me.xamSyntaxEditor1.Document.Save(fs)
The following topics provide additional information related to this topic.