Code Examples
  Home arrow Code Examples arrow Page 3 - Understanding 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

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

    Table of Contents:
  • Understanding the CompressedFolder Class
  • Examining the Properties
  • More on Properties
  • Examining the Exposed Methods

  • 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


    Understanding the CompressedFolder Class - More on Properties


    (Page 3 of 4 )

    Of my first three properties, the FullName (path and filename to the compressed folder) was the easiest to do first.  This needed to be a user-provided value.  The class user would need to indicate what compressed folder to create or open.  Very simply, this property would assign or retrieve an internal variable that contained the user’s supplied path and filename.

    The Filename and Path properties would be easy to code once the value of the FullName property had been assigned, since they are just pieces of that same string.  A little clever use of some string functions would parse out the pieces that I needed.  Remember, your code blocks don’t need to be fancy, just functional.  This simplest and most direct approach is usually the easiest and most efficient.

       Public Property Get Filename

           Filename = Right(FullName, Len(FullName) - InStrRev(FullName, ""))

       End Property

     

       Public Property Get Path

           Path = Left(FullName, InStrRev(FullName, ""))

       End Property

    For the Filename property, I simply found the last forward slash in the string returned by the FullName property and grabbed everything to the right of it.  According to standard Windows file naming conventions, this would be the folder or file name.

    Another revision might include an update that would prevent an extra forward slash at the end of the full path.  I chose to omit this for simplicity, and because compressed folders already contain a .zip extension indicating a file path rather than a folder path.

    The Path property should return the path to the compressed folder.  Here again I can look for the last forward slash in the string returned by the FullName property, this time grabbing everything to the left of it instead.  Essentially, this is the FullName value minus the Filename portion—the exact opposite of the last property.

    You might also notice that none of these properties allow public assignment.  Filename and Path are read-only, since they are dependent upon the value of the FullName property, and although the FullName property requires a user-submitted value, I’ve elected to not allow users to set this value directly.  It didn’t seem necessary to have my users supply a property and then call a method, when I could just as easily do everything in a single step without seeming complicated.

    Instead of assigning the FullName property directly, the property value is set by the Open method.  This also provided a convenient opportunity for me to do some error handling without having too much code inside of my property statements.

    In my opinion, Property blocks are for assigning and retrieving property values.  Any extraneous code belongs in a method of its own.  Code appears neater that way, and it provides a more modularized approach.

    More Code Examples Articles
    More By Nilpo


     

    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