|
|
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
|
|
|
|
|
|