make barcode with vb.net 18: Creating Windows Applications in Visual C#

Maker Code128 in Visual C# 18: Creating Windows Applications

18: Creating Windows Applications
ANSI/AIM Code 128 Drawer In C#
Using Barcode printer for Visual Studio .NET Control to generate, create Code 128B image in Visual Studio .NET applications.
www.OnBarcode.com
Decoding USS Code 128 In Visual C#
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
If the condition is true, you can get the list of filenames with the GetFileList( ) method you created before. Then you iterate through the list, deleting each file as you go. The FileInfo class also has a Delete( ) method that you can use here. Add this code to your handler:
Print PDF-417 2d Barcode In Visual C#.NET
Using Barcode creation for Visual Studio .NET Control to generate, create PDF 417 image in .NET framework applications.
www.OnBarcode.com
Data Matrix ECC200 Drawer In C#.NET
Using Barcode generator for .NET framework Control to generate, create DataMatrix image in .NET applications.
www.OnBarcode.com
List<FileInfo> fileNames = GetFileList( ); foreach ( FileInfo file in fileNames ) { try { // update the label to show progress lblStatus.Text = "Deleting " + txtTargetDir.Text + "\\" + file.Name + "..."; Application.DoEvents( ); file.Delete( ); } catch ( Exception ex ) { // you may want to do more than // just show the message MessageBox.Show( ex.Message ); } } lblStatus.Text = "Done."; Application.DoEvents( );
Barcode Generator In C#.NET
Using Barcode creation for .NET Control to generate, create Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Creating USS Code 39 In C#.NET
Using Barcode printer for Visual Studio .NET Control to generate, create Code39 image in .NET framework applications.
www.OnBarcode.com
This code is very similar to the copy code, except that the method that is called on the file is Delete( ). Everything is enclosed in a try block, for the same reason as before, and the status label is updated accordingly.
Printing UCC - 12 In C#.NET
Using Barcode drawer for .NET framework Control to generate, create UCC - 12 image in .NET applications.
www.OnBarcode.com
EAN - 14 Maker In C#.NET
Using Barcode drawer for VS .NET Control to generate, create EAN - 14 image in Visual Studio .NET applications.
www.OnBarcode.com
Handling the Cancel button event
Code 128B Creation In None
Using Barcode drawer for Microsoft Excel Control to generate, create Code 128 image in Office Excel applications.
www.OnBarcode.com
Making Code 128B In None
Using Barcode creation for Online Control to generate, create Code128 image in Online applications.
www.OnBarcode.com
The final button to handle is the Cancel button, which is quite trivial. Double-click the Cancel button to create its Click event handler, and add the following code:
PDF417 Maker In .NET
Using Barcode maker for .NET Control to generate, create PDF417 image in VS .NET applications.
www.OnBarcode.com
PDF 417 Encoder In None
Using Barcode printer for Font Control to generate, create PDF 417 image in Font applications.
www.OnBarcode.com
protected void btnCancel_Click (object sender, System.EventArgs e) { Application.Exit( ); }
Code 39 Extended Creation In None
Using Barcode printer for Software Control to generate, create Code-39 image in Software applications.
www.OnBarcode.com
Drawing Data Matrix ECC200 In VB.NET
Using Barcode creator for Visual Studio .NET Control to generate, create Data Matrix image in VS .NET applications.
www.OnBarcode.com
Source Code
Data Matrix ECC200 Creator In None
Using Barcode creator for Office Excel Control to generate, create Data Matrix 2d barcode image in Microsoft Excel applications.
www.OnBarcode.com
UPC Symbol Generation In None
Using Barcode maker for Microsoft Word Control to generate, create GTIN - 12 image in Word applications.
www.OnBarcode.com
There you go one complete, functional Windows application. Go ahead and test it out, but be careful what files you delete, because you won t get them back. You may also run into permission issues, if you re trying to access sensitive files or directories. Example 18-1 provides the full commented source code for this example.
Draw PDF-417 2d Barcode In Visual Basic .NET
Using Barcode creator for VS .NET Control to generate, create PDF-417 2d barcode image in .NET framework applications.
www.OnBarcode.com
Drawing QR Code 2d Barcode In None
Using Barcode generator for Office Word Control to generate, create QR-Code image in Office Word applications.
www.OnBarcode.com
Source Code
Creating USS Code 39 In Objective-C
Using Barcode maker for iPhone Control to generate, create Code 39 Extended image in iPhone applications.
www.OnBarcode.com
Barcode Creator In None
Using Barcode generation for Online Control to generate, create Barcode image in Online applications.
www.OnBarcode.com
|
ASP.NET
One of the goals of Microsoft s .NET initiative is to make it just as easy to create web applications as it is to create Windows applications. ASP.NET fulfills that goal for the Web. With ASP.NET, you can create applications using controls that are very similar to the ones you saw in this chapter, in a visual design environment that s nearly identical to the form designer you used here. The difference between creating a Windows application and a web page is that in ASP.NET, you can either place the controls visually, or view the HTML source for the page and add controls as though you were writing HTML. You store the code for the web page in a separate file, just as you did in this chapter, but in ASP.NET, that code can be written in either C# or Visual Basic; it makes no difference to the web page. If you re using the full version of Visual Studio 2008, you can already create ASP.NET web pages; you just need to select ASP.NET Web Page in the New Project dialog box. However, we ve written this book for the most part using C# Express, which doesn t support ASP.NET, so we won t go any further into the topic here. If you want to learn ASP.NET, you should find it quite easy. Your C# skills will be very useful, and you ll already be accustomed to the IDE from this book. Microsoft offers a free IDE called Visual Web Developer, which is the ASP.NET equivalent to C# Express. You may also want to pick up a copy of Learning ASP.NET 3.5, by Jesse Liberty et al. (O Reilly), which applies the learning style of this book to the topic of ASP.NET.
using using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; System.IO;
namespace FileCopier { public partial class FrmFileCopier : Form { private const int MaxLevel = 2; public FrmFileCopier( ) { InitializeComponent( ); FillDirectoryTree(tvwSource, true); FillDirectoryTree(tvwTargetDir, false); }
|
18: Creating Windows Applications
// the nested FileComparer class implements // IComparer, and allows you to compare two // FileInfo objects by file size. Note that // you're comparing large to small, so the // expected results are reversed. public class FileComparer : IComparer<FileInfo> { public int Compare(FileInfo file1, FileInfo file2) { if (file1.Length > file2.Length) { return -1; } if (file1.Length < file2.Length) { return 1; } return 0; } } // method for both TreeView controls that fills the TreeViews // with the contents of the local drives. private void FillDirectoryTree(TreeView tvw, bool isSource) { // clear the tree first tvw.Nodes.Clear( ); // find the root drives for root nodes string[] strDrives = Environment.GetLogicalDrives( ); // Iterate through the drives, adding them to the tree foreach (string rootDirectoryName in strDrives) { try { // If a drive is not ready, it will be skipped DirectoryInfo dir = new DirectoryInfo(rootDirectoryName); dir.GetDirectories( ); // forces an exception if the drive isn't ready // create a new TreeNode object TreeNode ndRoot = new TreeNode(rootDirectoryName); // add the TreeNode to the TreeView's collection // for each root directory tvw.Nodes.Add(ndRoot); // // // Add subdirectory nodes. If the Treeview is the source, then also get the filenames.
Copyright © OnBarcode.com . All rights reserved.