Skip Navigation LinksHome > News Groups > microsoft.public.sharepoint.portalserver.development

.NET development starting at $25 per hour

How to trap virus error when uploading file to sharepoint programmatically.
From "eforce" on 12/12/2006 2:07:14 PM
Hi,

We are using ForeFront Security for SharePoint and WSS V.3.

We are using SharePoint Object Model to upload some file to a Document
Library.

However, in the event when the uploaded file contain a virus, we will need
to trap the error and return a "friendly" msg to the UI.

Any idea how we can do this?

Thanks

Regards

Willey

Below is the current code we used to upload a file to Document Library:

String destURL = SPEncode.UrlEncodeAsUrl(destFiles.Folder.Url) + "/" +
SPEncode.UrlEncodeAsUrl(fileName);

SPFile spFile = destFiles.Add(destURL, file.InputStream, true); //overwrite


Re: How to trap virus error when uploading file to sharepoint programmatically.
From "Andy" on 12/12/2006 9:49:33 AM

Don't know anything about your security module, but you could put a
try/catch around your code where the catch only handles an exception.
Upload a file known to contain a virus and see what exception is thrown
(this will be contained in result). The message will contain the name
of the exception, which will likely be a special class defined in your
security module.

You can then re-write your code to check for the specific name of the
exception thrown (perhaps if you add your security .dll as a reference
to your project intellisense may actually give you other fields
available for that exception) as a way to test for infected files.

dim result as system.string

try

...your code goes here...

Catch e As Exception
result = e.Message
end try
Re: How to trap virus error when uploading file to sharepoint programmatically.
From "Andy" on 12/12/2006 10:06:52 AM
Actually, you can also use the sharepoint lists webservice and call the
method GetListItems. This method returns a list of properties for a
sharepoint document, one of which is VirusStatus.

See the SPS SDK for more details.

Andy
Re: How to trap virus error when uploading file to sharepoint programmatically.
From "Andy" on 12/12/2006 12:19:44 PM
And, there is a similar GetListItems method on the SiteData webservice
that is easier to use.

Related Items

RE: Change the icon left to the Title
Changing Checkbox Values on the Upload Document Page
Re: Referencing a SharePoint 2007 Web Service
SiteGroups quota limit?
RE: BDC List WebPart error The Business Data Catalog is configured
RE: How to make table use default WSS stlysheet
Store list on Quick Launch Bar
Re: SharePoint 2003 web services security
2.0 application hitting the sharepoint aip
Re: Different labels in different views