|
|
Rank: Newbie
Groups: Registered
Joined: 11/18/2009 Posts: 4
|
In post-processing of a collection of files I do a virus scan of the files. If the virus scan returns true on a file I delete the file. Is there a way to either update the status of the file to indicate it was deleted because a virus was detected of delete the information about the file from the UploadedFiles collection?
|
|
|
Rank: Administration

Groups: Administrators
Joined: 7/7/2005 Posts: 1,586 Location: Scottsdale, AZ
|
So you're doing virus scanning in the UploadComplete event server side, and trying to remove the file from the UploadedFiles collection so subsequent code won't have to deal with it? The UploadedFiles collection is readonly as it represents all of the files that were uploaded, so you won't be able to remove it directly. What you could do is to create a new collection that initially contains all of the files from the UploadedFiles collection, and then use that in your code. That will allow you to remove the items in your virus scan routine, and then interact with that collection with your subsequent code. Something like this:
List<UploadedFile> internalFiles = new List<UploadedFile>(e.UploadedFiles);
Will that work for your scenario?
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/18/2009 Posts: 4
|
Yes, I initially considered that. I am surprised that there isn't a way to update the collection in post processing or the status. Thanks for getting back to me.
|
|
|
Rank: Administration

Groups: Administrators
Joined: 7/7/2005 Posts: 1,586 Location: Scottsdale, AZ
|
We considered this, but made the design decision to make the collection read-only to keep the interface clean, simple, and self explanatory. Once the files have been uploaded, the set of files that were uploaded is immutable. Creating another list to use if you want to make modifications is dead simple, and makes your intention clear. We thought about allowing a mutable collection and deleting the physical file when an item is removed, but that is kind of a hidden side-effect that could confuse.
|
|
|
|
Guest |