HttpFileCollection.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / HttpFileCollection.cs / 1305376 / HttpFileCollection.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

/* 
 * Collection of posted files for the request intrinsic 
 *
 * Copyright (c) 1998 Microsoft Corporation 
 */

namespace System.Web {
 
    using System.Runtime.InteropServices;
    using System.Collections; 
    using System.Collections.Specialized; 
    using System.Security.Permissions;
    using System.Web.Util; 


    /// 
    ///     
    ///       Accesses incoming files uploaded by a client (using
    ///       multipart MIME and the Http Content-Type of multipart/formdata). 
    ///     
    /// 
    public sealed class HttpFileCollection : NameObjectCollectionBase { 
        // cached All[] arrays
        private HttpPostedFile[] _all;
        private String[] _allKeys;
 
        internal HttpFileCollection() : base(Misc.CaseInsensitiveInvariantKeyComparer) {
        } 
 

        ///  
        ///    [To be supplied.]
        /// 
        public void CopyTo(Array dest, int index) {
            if (_all == null) { 
                int n = Count;
                _all = new HttpPostedFile[n]; 
                for (int i = 0; i < n; i++) 
                    _all[i] = Get(i);
            } 

            if (_all != null) {
                _all.CopyTo(dest, index);
            } 
        }
 
        internal void AddFile(String key, HttpPostedFile file) { 
            _all = null;
            _allKeys = null; 

            BaseAdd(key, file);
        }
 
        //
        //  Access by name 
        // 

 
        /// 
        ///    
        ///       Returns a file from
        ///       the collection by file name. 
        ///    
        ///  
        public HttpPostedFile Get(String name) { 
            return(HttpPostedFile)BaseGet(name);
        } 


        /// 
        ///    Returns item value from collection. 
        /// 
        public HttpPostedFile this[String name] 
        { 
            get { return Get(name);}
        } 

        //
        // Indexed access
        // 

 
        ///  
        ///    
        ///       Returns a file from 
        ///       the file collection by index.
        ///    
        /// 
        public HttpPostedFile Get(int index) { 
            return(HttpPostedFile)BaseGet(index);
        } 
 

        ///  
        ///    
        ///       Returns key name from collection.
        ///    
        ///  
        public String GetKey(int index) {
            return BaseGetKey(index); 
        } 

 
        /// 
        ///    
        ///       Returns an
        ///       item from the collection. 
        ///    
        ///  
        public HttpPostedFile this[int index] 
        {
            get { return Get(index);} 
        }

        //
        // Access to keys and values as arrays 
        //
 
 
        /// 
        ///     
        ///       Creates an
        ///       array of keys in the collection.
        ///    
        ///  
        public String[] AllKeys {
            get { 
                if (_allKeys == null) 
                    _allKeys = BaseGetAllKeys();
 
                return _allKeys;
            }
        }
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK