.net barcode reader camera Figure 7-11. Extracting the folder name in Font

Generate PDF 417 in Font Figure 7-11. Extracting the folder name

Figure 7-11. Extracting the folder name
PDF 417 Printer In None
Using Barcode generator for Font Control to generate, create PDF-417 2d barcode image in Font applications.
www.OnBarcode.com
Printing European Article Number 13 In None
Using Barcode maker for Font Control to generate, create EAN 13 image in Font applications.
www.OnBarcode.com
CHAPTER 7 AUTOMATION WITH CONSOLE-BASED TESTWARE
Creating PDF-417 2d Barcode In None
Using Barcode maker for Font Control to generate, create PDF 417 image in Font applications.
www.OnBarcode.com
Draw Code 128 Code Set A In None
Using Barcode generation for Font Control to generate, create Code128 image in Font applications.
www.OnBarcode.com
Note For an overview on arrays, please see Appendix B.
Painting USS Code 39 In None
Using Barcode generator for Font Control to generate, create Code39 image in Font applications.
www.OnBarcode.com
Encode GS1 - 12 In None
Using Barcode maker for Font Control to generate, create UPC-A image in Font applications.
www.OnBarcode.com
Copying the Files from the Share
Barcode Maker In None
Using Barcode printer for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
British Royal Mail 4-State Customer Barcode Maker In None
Using Barcode creator for Font Control to generate, create RM4SCC image in Font applications.
www.OnBarcode.com
Once you have identified the folder on the share, you should write some code that will get a list of all the files in the folder automatically. The GetFiles() method in the System.IO.Directory namespace can do just that. It returns an array of the filenames it finds in the folder you specify. This array contains an element for each file found. It also includes the full path as well, as noted in Figure 7-12.
PDF417 Drawer In C#
Using Barcode printer for .NET Control to generate, create PDF 417 image in .NET framework applications.
www.OnBarcode.com
PDF 417 Drawer In .NET
Using Barcode encoder for VS .NET Control to generate, create PDF-417 2d barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Figure 7-12. Using the GetFiles() method To copy the individual files, you separate the filename from the path using a For-Each loop along with the Copy() method of the File class, as shown in Figure 7-13. Since this method requires the full pathname for the source file, we just pass it the data. For instance, we could create a variable called strFullFileName, have it hold the string "\\lab1\share\testapp\ TestApp.exe", and indicate what the destination would be: c:\TestApp\TestApp.exe.
Creating GS1 DataBar Expanded In Java
Using Barcode maker for Java Control to generate, create GS1 DataBar-14 image in Java applications.
www.OnBarcode.com
Generate Code 128 Code Set C In Objective-C
Using Barcode creation for iPad Control to generate, create USS Code 128 image in iPad applications.
www.OnBarcode.com
Figure 7-13. Using the Copy() method To review the process, you create a folder with all the files you need, place it on the network share, pass in the correct name and path to your installer program, and, when the process succeeds, return a status of Completed. Listing 7-16 is an example of what that code would look like.
Data Matrix ECC200 Scanner In VB.NET
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Painting Code 128 Code Set C In Visual Basic .NET
Using Barcode maker for .NET Control to generate, create Code128 image in Visual Studio .NET applications.
www.OnBarcode.com
CHAPTER 7 AUTOMATION WITH CONSOLE-BASED TESTWARE
EAN / UCC - 14 Creator In C#.NET
Using Barcode encoder for .NET Control to generate, create GS1-128 image in .NET framework applications.
www.OnBarcode.com
GS1 - 13 Creation In VS .NET
Using Barcode generation for ASP.NET Control to generate, create European Article Number 13 image in ASP.NET applications.
www.OnBarcode.com
Listing 7-16. Downloading Application Files VB .NET Public Shared Function DownloadAppFiles(ByVal PathAndName As String) As String Dim strStatus As String = "" Dim strFileListing() As String Dim strFullFileName As String Dim strSimpleFileName As String Dim strAppName As String Dim intIndex As Int32 'Get only the folders name from the full name intIndex = PathAndName.LastIndexOf("\") strAppName = PathAndName.Substring(intIndex + 1) Try 'a) Create a folder for your Testware as needed Dim DI As New System.IO.DirectoryInfo("c:\" + strAppName) If Not DI.Exists Then 'Find out if there already is a folder by that name DI.Create() End If 'b) Go to Network share and copy the files in 'the application folder to local drive, overwrite as needed strFileListing = System.IO.Directory.GetFiles(PathAndName) For Each strFullFileName In strFileListing intIndex = strFullFileName.LastIndexOf("\") strSimpleFileName = strFullFileName.Substring(intIndex + 1) System.IO.File.Copy _ (strFullFileName, "c:\" + strAppName + "\" + strSimpleFileName, True) Next 'c) Indicate the errors status strStatus = "Completed" Catch ex As Exception Console.WriteLine(ex.ToString + vbCrLf + "Press any key to continue...") Console.ReadLine() strStatus = "Failed" End Try Return strStatus End Function
Print DataMatrix In Visual C#
Using Barcode creator for Visual Studio .NET Control to generate, create ECC200 image in .NET applications.
www.OnBarcode.com
EAN / UCC - 13 Generation In Java
Using Barcode creation for Java Control to generate, create EAN / UCC - 14 image in Java applications.
www.OnBarcode.com
CHAPTER 7 AUTOMATION WITH CONSOLE-BASED TESTWARE
GTIN - 12 Maker In .NET Framework
Using Barcode printer for Visual Studio .NET Control to generate, create GS1 - 12 image in .NET framework applications.
www.OnBarcode.com
Code 128B Drawer In Java
Using Barcode generation for BIRT reports Control to generate, create Code 128C image in BIRT reports applications.
www.OnBarcode.com
Saving Testware Reports to a Central Network Share
As you may have noticed, the last three examples each returns the status of Completed or Failed. Along with the actual installation, you could automate a report being created and sent to a share for viewing later. To demonstrate this, we have created the ReportOnInstall() method (see Listing 7-17). Listing 7-17. Creating an HTML Report VB .NET Public Shared Function ReportOnInstall(ByVal ReportFileName) As String Dim strStatus As String = "" Dim objSR As System.IO.StreamReader Dim objSW As System.IO.StreamWriter Dim strReportData As String = "" Dim strComputer As String = My.Computer.Name Try 'Open PCInfo.csv and Append the install info objSR = New System.IO.StreamReader("c:\PCInfo\PCInfo.csv") strReportData = "<b>*** " + strComputer + " = Done ***</b><p> " strReportData += objSR.ReadToEnd strReportData += "<hr>" objSR.Close() objSW = New System.IO.StreamWriter(ReportFileName, True) objSW.Write(strReportData) objSW.Close() strStatus = "Completed" Catch ex As Exception Console.WriteLine(ex.ToString + vbCrLf + "Press any key to continue...") Console.ReadLine() strStatus = "Failed" End Try Return strStatus End Function The first part of the ReportOnInstall() method gets a StreamReader, a StreamWriter, and the computer s name. Then, within the Try-Catch block, we add some very basic formatting we wanted to see in our report heading by using stars and the computer s name. Next, we read the contents of the .csv file we received from Exercise 7-1 and place it into a text string. We also add some HTML tags, such as <hr/>, which create a horizontal rule across the screen of a web browser. From this, you may have guessed that we are saving our report to a file with an .html extension. Once we have the report data and some basic formatting, we are ready to write the contents to the report file on a network share.
Copyright © OnBarcode.com . All rights reserved.