Leadtools.Barcode Namespace > BarcodeReadOptions Class > Save Method : Save(String) Method |
'Usage Dim instance As BarcodeReadOptions Dim fileName As String instance.Save(fileName)
function Leadtools.Barcode.BarcodeReadOptions.Save(String)( fileName )
The load/save methods are provided as helper methods for the user. The BarcodeEngine, BarcodeReader and BarcodeWriter do not use these methods internally.
To load the data previously saved into an XML file, use BarcodeReadOptions.Load(string fileName).
To save and load data to an XML stream, use BarcodeReadOptions.Save(Stream stream) and BarcodeReadOptions.Load(Stream stream).
To save the default read options used by BarcodeReader, use BarcodeReader.SaveOptions
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.Forms Imports Leadtools.Barcode Imports Leadtools.ImageProcessing Public Sub BarcodeReadOptions_LoadSaveExample() Dim xmlFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "MyOptions.xml") ' Create the options Dim options1 As New OneDBarcodeReadOptions() ' Show its values ShowOptions("Default 1", options1) ' Change some of the values options1.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical options1.ReturnCheckDigit = BarcodeReturnCheckDigit.Default options1.EnableErrorCheck = True ShowOptions("New Options 1", options1) ' Save it to disk options1.Save(xmlFileName) ' Create new options Dim options2 As New OneDBarcodeReadOptions() ' Show its values ShowOptions("Default 2", options2) ' Load the previously saved options options2.Load(xmlFileName) ' Show its values, should be the same as "New Options 1" ShowOptions("Loaded 2", options2) End Sub Private Shared Sub ShowOptions(ByVal message As String, ByVal options As OneDBarcodeReadOptions) ' We will only show some of the options in this example Console.WriteLine(message) Console.WriteLine(" SearchDirection: {0}", options.SearchDirection) Console.WriteLine(" ReturnCheckDigit: {0}", options.ReturnCheckDigit) Console.WriteLine(" EnableErrorCheck: {0}", options.EnableErrorCheck) Console.WriteLine("----------------") End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
using Leadtools; using Leadtools.Codecs; using Leadtools.Forms; using Leadtools.Barcode; using Leadtools.ImageProcessing; public void BarcodeReadOptions_LoadSaveExample() { string xmlFileName = Path.Combine(LEAD_VARS.ImagesDir, "MyOptions.xml"); // Create the options OneDBarcodeReadOptions options1 = new OneDBarcodeReadOptions(); // Show its values ShowOptions("Default 1", options1); // Change some of the values options1.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; options1.ReturnCheckDigit = BarcodeReturnCheckDigit.Default; options1.EnableErrorCheck = true; ShowOptions("New Options 1", options1); // Save it to disk options1.Save(xmlFileName); // Create new options OneDBarcodeReadOptions options2 = new OneDBarcodeReadOptions(); // Show its values ShowOptions("Default 2", options2); // Load the previously saved options options2.Load(xmlFileName); // Show its values, should be the same as "New Options 1" ShowOptions("Loaded 2", options2); } private static void ShowOptions(string message, OneDBarcodeReadOptions options) { // We will only show some of the options in this example Console.WriteLine(message); Console.WriteLine(" SearchDirection: {0}", options.SearchDirection); Console.WriteLine(" ReturnCheckDigit: {0}", options.ReturnCheckDigit); Console.WriteLine(" EnableErrorCheck: {0}", options.EnableErrorCheck); Console.WriteLine("----------------"); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }