ASP.NET
  Home arrow ASP.NET arrow Page 2 - Slapping Together a Photo Gallery in ASP.N...
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? 
ASP.NET

Slapping Together a Photo Gallery in ASP.NET Part II
By: Harish Kamath
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 22
    2005-04-11

    Table of Contents:
  • Slapping Together a Photo Gallery in ASP.NET Part II
  • Working with Files
  • Of Albums and Photos
  • Two Sides of a Coin
  • My Gallery
  • My Gallery - Demystified
  • Conclusion

  • 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


    Slapping Together a Photo Gallery in ASP.NET Part II - Working with Files


    (Page 2 of 7 )

    The first example in this article introduces the File() object. This is a counterpart of the Directory() object with which you're already familiar.

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.IO" %>
    <SCRIPT language="C#" runat="server">
    void Page_Load(Object sender, EventArgs e) {

     // path to an image file
     string strPhotoFilePath = "E:\\inetpub\\wwwroot\\Gallery\\
    Australia\\DSCN3944.JPG";

     // check if file exists
     if(File.Exists(strPhotoFilePath)) {

      output.Text = "The file <U>" + strPhotoFilePath + "</U> exists.";

     } else {

      output.Text = "Sorry, the  file <U>" + strPhotoFilePath + "</U> does not exist.";
     }
    }
    </SCRIPT>
    <HTML>
    <HEAD>
        <TITLE>My Gallery</TITLE>
        <BASEFONT face="Arial" />
    </HEAD>
    <BODY>
        <asp:Label id="output" runat="server" />
    </BODY>
    </HTML>

    Once again, I have to deal with two familiar scenarios: 

    the specified file either exists on the server...

    ... or it does not.

    I've already stated that the File() object is a counterpart of the Directory() object. So, it goes without saying that it is necessary to "import" the "System.IO" assembly into my ASP.NET script.

    The "strPhotoFilePath" string variable is used to store the path to the file that I wish to access. The all-new File() object comes with list of static methods; I've invoked the Exists() method, whose behavior is similar to the Exists() method of the Directory() object. This method returns a "true" value if the file (or directory) exists, and a "false" value otherwise.

    While the above example may not necessarily trouble your gray cells, the example in the next section will definitely demonstrate the usefulness of this innocuous File() object.

    So, what are you waiting for? Flip the page and get moving!

    More ASP.NET Articles
    More By Harish Kamath


     

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





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