About.aspx.vb
Public Class About Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub End Class
Default.aspx.vb
Imports System.IO Imports Bytescout.BarCodeReader Public Class _Default Inherits System.Web.UI.Page Private Sub UploadButton_Click(sender As Object, e As System.EventArgs) Handles UploadButton.Click Dim savePath As String = "\uploads\" If (FileUpload1.HasFile) Then Dim virtualFilePath As String = Path.Combine(savePath, FileUpload1.FileName) Dim serverFilePath As String = Server.MapPath(virtualFilePath) If Not Directory.Exists(Path.GetDirectoryName(serverFilePath)) Then Directory.CreateDirectory(Path.GetDirectoryName(serverFilePath)) End If FileUpload1.SaveAs(serverFilePath) Dim image As System.Drawing.Image = Nothing Try Using fileStream As FileStream = File.OpenRead(serverFilePath) image = System.Drawing.Image.FromStream(fileStream) End Using Catch ex As Exception End Try If image Is Nothing Then UploadStatusLabel.Visible = True UploadStatusLabel.Text = "Your file is not an image." Image1.Visible = False ListBox1.Visible = False Else UploadStatusLabel.Visible = False Image1.ImageUrl = virtualFilePath Image1.Visible = True Image1.Width = image.Width Image1.Height = image.Height ListBox1.Items.Clear() ListBox1.Visible = True FindBarcodes(serverFilePath) If ListBox1.Items.Count = 0 Then ListBox1.Items.Add("No barcodes found") End If End If Else 'Notify the user that a file was not uploaded. UploadStatusLabel.Text = "You did not specify a file to upload." End If End Sub Private Sub FindBarcodes(fileName As String) Dim reader As Reader = New Reader() ' Limit search to 1D barcodes only (exclude 2D barcodes to speed up the search). ' Change to bc.BarcodeTypesToFind.SetAll() to scan for all supported 1D and 2D barcodes ' or select specific type, e.g. bc.BarcodeTypesToFind.PDF417 = True reader.BarcodeTypesToFind.SetAll1D() ' reader.MediumTrustLevelCompatible = True ' uncomment this line to enable Medium Trust compatible mode (slows down the recognition process as direct image data access is disabled in Medium Trust mode) reader.ReadFromFile(fileName) For Each barcode As FoundBarcode In reader.FoundBarcodes ListBox1.Items.Add(String.Format("{0} : {1}", barcode.Type, barcode.Value)) Next End Sub End Class
Global.asax.vb
Imports System.Web.SessionState Public Class Global_asax Inherits System.Web.HttpApplication Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ' Fires when the application is started End Sub Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ' Fires when the session is started End Sub Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) ' Fires at the beginning of each request End Sub Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs) ' Fires upon attempting to authenticate the use End Sub Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) ' Fires when an error occurs End Sub Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) ' Fires when the session ends End Sub Sub Application_End(ByVal sender As Object, ByVal e As EventArgs) ' Fires when the application ends End Sub End Class
Site.Master.vb
Public Class Site Inherits System.Web.UI.MasterPage Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub End Class
Web.config
<?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <connectionStrings> <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" /> <authentication mode="Forms"> <forms loginUrl="~/Account/Login.aspx" timeout="2880" /> </authentication> <membership> <providers> <clear/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> </providers> </membership> <profile> <providers> <clear/> <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/> </providers> </profile> <roleManager enabled="false"> <providers> <clear/> <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" /> <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> </providers> </roleManager> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>
Click here to get your Free Trial version of the SDK
also available as: