Batch read barcodes to csv with barcode reader sdk is simple to apply in C# if you use these source codes below. ByteScout Barcode Suite is the set that includes three different SDK products to generate barcodes, read barcodes and read and write spreadsheets: Barcode SDK, Barcode Reader SDK and Spreadsheet SDK. It can batch read barcodes to csv with barcode reader sdk in C#.
These C# code samples for C# guide developers to speed up coding of the application when using ByteScout Barcode Suite. This C# sample code is all you need for your app. Just copy and paste the code, add references (if needs to) and you are all set! Applying C# application mostly includes various stages of the software development so even if the functionality works please test it with your data and the production environment.
If you want to try other source code samples then the free trial version of ByteScout Barcode Suite is available for download from our website. Just try other source code samples for C#.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
using System; using System.Collections.Generic; using System.Diagnostics; using Bytescout.BarCodeReader; namespace ImagePDFBarcodeToCSV { class Program { static void Main(string[] args) { try { //Read Barcode Process Reader reader = new Reader(); reader.RegistrationKey = "demo"; reader.RegistrationName = "demo"; // Set Barcode type to find reader.BarcodeTypesToFind.All = true; // Output list List<CSVOutputFormat> lstCSVOutput = new List<CSVOutputFormat>(); // Get all files in folder, and iterate through each file var files = System.IO.Directory.GetFiles("BarcodeFiles"); foreach (var fileName in files) { /* ----------------------------------------------------------------------- NOTE: We can read barcodes from specific page to increase performance . For sample please refer to "Decoding barcodes from PDF by pages" program. ----------------------------------------------------------------------- */ // Read barcodes FoundBarcode[] barcodes = reader.ReadFrom(fileName); foreach (FoundBarcode code in barcodes) { lstCSVOutput.Add(new CSVOutputFormat { barcodeValue = code.Value, barcodeType = code.Type.ToString(), scanDateTime = DateTime.Now.ToString(), fileName = fileName }); } } Console.WriteLine("Total {0} barcode found in {1} file.", lstCSVOutput.Count, files.Length); // cleanup reader.Dispose(); // Export to CSV ExportToCsv(lstCSVOutput); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("Press enter key to exit..."); Console.ReadLine(); } /// <summary> /// Exports to CSV /// </summary> /// <param name="lstCSVOutput"></param> private static void ExportToCsv(List<CSVOutputFormat> lstCSVOutput) { System.Text.StringBuilder csvOutputContent = new System.Text.StringBuilder(string.Empty); csvOutputContent.Append("Barcode Value,Barcode Type,Scan DateTime,File Name"); foreach (var item in lstCSVOutput) { csvOutputContent.AppendFormat("\r\n{0},{1},{2},{3}", item.barcodeValue, item.barcodeType, item.scanDateTime, item.fileName); } System.IO.File.WriteAllText("output.csv", csvOutputContent.ToString()); Process.Start("output.csv"); } } class CSVOutputFormat { public string barcodeValue { get; set; } public string barcodeType { get; set; } public string scanDateTime { get; set; } public string fileName { get; set; } } }
In this tutorial, we will read Barcodes in CSV format. Let’s copy the sample code and paste it into the Visual Studio editor. I added the sample code link in the description box below. To read barcodes, we will use the ‘ByteScout Barcode Reader SDK’. You can add a reference to the Barcode Reader SDK DLL and the Solution Explorer. Right-click on reference and select Add reference. Look at the ‘ByteScout Barcode Reader SDK’ and add. Then add your registration name and registration key and their related properties accordingly. You can get your license details in the ByteScout dashboard. Next set the ‘BarcodeTypesToFind.All = true’.
After that, let’s copy the sample files into our folder. Then we will add our sample file in the solution explorer and set the copy to the output directory to ‘copy always’. We will now load our sample files to our system directory. Our output will be in CSV format. Our CSV output will get and read the barcode value, barcode type, scan date, time and file name.
Now let’s run the program. Our program found eight bar codes in three files. Here are the sample barcodes that we use and here’s the output.
60 Day Free Trial or Visit ByteScout Barcode Suite Home Page
Explore ByteScout Barcode Suite Documentation
Explore Samples
Sign Up for ByteScout Barcode Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: