Minimal XML files

Topics: Developer Forum, User Forum
Nov 3, 2013 at 2:02 AM
Edited Nov 3, 2013 at 2:05 AM
The following code will create minimal XML files for each of the languages supported by the native Scintilla.dll. They will not restore functionality but they will keep the program from crashing if the Scintilla1.ConfigurationManager.CustomLocation is used.
    Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click
        ' Note that you will need "FULL RIGHTS" for the target directory
        Dim TargetPath As String = "C:\ScintillaNET\XML\"
        Dim TargetFile As String = ""
        Dim T As String = ""
        Dim Languages() As String = [Enum].GetNames(GetType(ScintillaNET.Lexer))
        Array.Sort(Languages)
        For Each Lang In Languages
            ' build the file name
            TargetFile = TargetPath & Lang & ".xml"
            ' See if already exists
            If Dir(TargetFile) = "" Then
                ' example minimal file
                '<?xml version="1.0" encoding="utf-8"?>
                '<!-- This is a minimal language configuration file for ScintillaNET -->
                '<ScintillaNET>
                '<Language Name="ada">
                '<Lexer LexerName="ada"/>   
                '</Language>
                '</ScintillaNET>
                ' ScintillaNET uses Microsoft's XML reader. 
                ' This is an extremley non-fault tolerate piece of software.
                ' A single byte out of place anywhere will bring it to its knees.
                T = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & _
                      " encoding=" & Chr(34) & "utf-8" & Chr(34) & "?>" & vbCrLf
                T = T & "<!-- This is a minimal language configuration" & _
                      " file for ScintillaNET -->" & vbCrLf
                T = T & "<ScintillaNET>" & vbCrLf
                T = T & "<Language Name=" & Chr(34) & Lang & Chr(34) & ">" & vbCrLf
                T = T & "<Lexer LexerName=" & Chr(34) & Lang & Chr(34) & "/>" & vbCrLf
                T = T & "</Language>" & vbCrLf
                T = T & "</ScintillaNET>"
                ' It makes absolutely no differences which of these you use. 
                ' The result is the same.
                ' My.Computer.FileSystem.WriteAllText(TargetFile, _
                         T, False, System.Text.Encoding.ASCII)
                My.Computer.FileSystem.WriteAllText(TargetFile, _ 
                         T, False, System.Text.Encoding.UTF8)
            End If
        Next

    End Sub