SlickUpload
Welcome Guest Search | Active Topics | Log In | Register

Remove information about uploaded file Options
boblpope
#1 Posted : Monday, November 23, 2009 3:26:51 PM
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?

Axosoft
#2 Posted : Monday, November 23, 2009 9:18:30 PM
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?

boblpope
#3 Posted : Tuesday, November 24, 2009 12:41:18 AM
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.
Axosoft
#4 Posted : Tuesday, November 24, 2009 12:42:32 PM
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.

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.