Ejemplo n.º 1
0
        private void InitializeFiles()
        {
            if (IsDesignTime || IsFilesInitialized)
            {
                return;
            }
            // Initialize the Files property
            ArrayList fileArrayList = new ArrayList();

            if (UploadModule.IsEnabled)
            {
                UploadedFileCollection allFiles = UploadModule.Files;
                // Get only the files that were uploaded from this control
                for (int i = 0; allFiles != null && i < allFiles.Count; i++)
                {
                    if (allFiles.GetKey(i) == this.UniqueID)
                    {
                        UploadedFile uploadedFile = allFiles[i];
                        if (uploadedFile.IsUploaded)
                        {
                            fileArrayList.Add(allFiles[i]);
                        }
                    }
                }
            }
            else
            {
                HttpFileCollection allFiles = HttpContext.Current.Request.Files;
                // Get only the files that were uploaded from this control
                for (int i = 0; allFiles != null && i < allFiles.Count; i++)
                {
                    if (allFiles.GetKey(i) == this.UniqueID)
                    {
                        UploadedFile uploadedFile
                            = UploadModule.ConvertToUploadedFile(this.UniqueID, (HttpPostedFile)allFiles[i]);
                        if (uploadedFile == null)
                        {
                            continue;
                        }
                        if (uploadedFile.IsUploaded)
                        {
                            fileArrayList.Add(uploadedFile);
                        }
                        else
                        {
                            uploadedFile.Dispose();
                        }
                    }
                }
            }
            _files = new UploadedFile[fileArrayList.Count];
            Array.Copy(fileArrayList.ToArray(), _files, _files.Length);
            IsFilesInitialized = true;
        }
Ejemplo n.º 2
0
        internal UploadedFileCollection GetReadOnlyCopy()
        {
            UploadedFileCollection readOnlyCollection = new UploadedFileCollection();

            lock (_SyncRoot)
            {
                for (int i = 0; i < Count; i++)
                {
                    readOnlyCollection.Add(this.GetKey(i), this.Get(i));
                }
                readOnlyCollection.IsReadOnly = true;
            }
            return(readOnlyCollection);
        }
Ejemplo n.º 3
0
 public void CopyFrom(object source)
 {
     UploadState src = (UploadState)source;
     this._BytesPerSec = src._BytesPerSec;
     this._BytesRead = src._BytesRead;
     this._BytesTotal = src._BytesTotal;
     this._Failure = src._Failure;
     this._FileBytesRead = src._FileBytesRead;
     this._Files = src._Files;
     this._MultiRequestObject = src._MultiRequestObject;
     this._PostBackID = src._PostBackID;
     this._ProcessingStateDict = src._ProcessingStateDict;
     this._Rejection = src._Rejection;
     this._Status = src._Status;
     this.BytesReadAtLastMark = src.BytesReadAtLastMark;
     this.IsMerging = src.IsMerging;
     this.TimeOfFirstByte = src.TimeOfFirstByte;
     this.TimeOfLastMark = src.TimeOfLastMark;
     this.TimeOfLastMerge = src.TimeOfLastMerge;
     this.UploadStateAtLastMerge = src.UploadStateAtLastMerge;
 }
Ejemplo n.º 4
0
 internal UploadedFileCollection GetReadOnlyCopy()
 {
     UploadedFileCollection readOnlyCollection = new UploadedFileCollection();
     lock (_SyncRoot)
     {
         for (int i = 0; i < Count; i++)
             readOnlyCollection.Add(this.GetKey(i), this.Get(i));
         readOnlyCollection.IsReadOnly = true;
     }
     return readOnlyCollection;
 }