Code Examples
  Home arrow Code Examples arrow Page 4 - Implementing the CompressedFolder Class
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Implementing the CompressedFolder Class
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-03-19

    Table of Contents:
  • Implementing the CompressedFolder Class
  • More internal methods
  • Examining the Support Methods
  • Wrapping up

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Implementing the CompressedFolder Class - Wrapping up


    (Page 4 of 4 )

    Private Sub Class_Initialize

       Set objShell = CreateObject("Shell.Application")

       Set objFso   = CreateObject("Scripting.FileSystemObject")

    End Sub

     

    Private Sub Class_Terminate

       Set objShell = Nothing

       Set objFso   = Nothing

    End Sub

    The last two support methods are actually event handlers for the class itself.  Thus, when a class is created or destroyed, events are fired.  By capturing these events, a programmer has a place to execute code when a class is created or destroyed.  For illustration purposes I’ve used these events as a common place to create and release the global objects used by my class.

    Implementing the class in your scripts is quite simple.  You’ll need to copy and paste the class into your script, and then instantiate it with the New keyword.  Here’s what the class would look like in action to create a compressed folder and add a file to it.

    Set objZipFolder = New CompressedFolder

    objZipFolder.Create"C:archive.zip"

    objZipFolder.Add "C:myfile.txt", vbTrue

     

    WScript.Echo "You have successfully added a file to " & objZipFolder.Filename

    Set objZipFolder = Nothing

    Now you’ve seen how to create the class, and hopefully you also have a better understanding of the code and concepts that went into its development.  There is no right or wrong way to code a particular class.  Experience will teach you the most effective practices for accomplishing a task.  I hope that you’ve gained a little insight into my own coding practices, and that you can take some of what I"ve shown here to help you create your own.  Until next time, keep coding!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    CODE EXAMPLES ARTICLES

    - Bipartite Graphs
    - Connectivity in Graphs
    - The Ford-Fulkerson Algorithm
    - Critical Paths
    - The Bellman-Ford and Roy-Floyd Algorithms
    - Shortest Path Algorithms in Graphs
    - Minimum Spanning Tree
    - Articulation Edges and Vertexes
    - Circles and Connectivity in Graphs
    - Depth-First Search in Graphs
    - Breadth-First Search in Graphs
    - The Prufer Code and the Floyd-Warshall Algor...
    - An Insight into Graphs
    - Coding a Custom Object with WSC
    - Creating a Custom Object with WSC





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek