13.07.2015 Views

Microsoft SharePoint. Building Office 2007 Solutions in VB 2005 ...

Microsoft SharePoint. Building Office 2007 Solutions in VB 2005 ...

Microsoft SharePoint. Building Office 2007 Solutions in VB 2005 ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 9 ■ SHAREPOINT AND MICROSOFT OFFICE 363'Make sure this is a DOCX fileIf Not (strExtension.ToUpper = "DOCX") ThenThrow New Exception("Only DOCX files can be cleaned.")End If'Download fileDim objClient As System.Net.WebClient = New System.Net.WebClientobjClient.Credentials = System.Net.CredentialCache.DefaultCredentialsobjClient.DownloadFile(strSource, strDownPath)'Sanitize documentDim objWorker As WordCleaner.Worker = New WordCleaner.WorkerobjWorker.Sanitize(strDownPath)'Upload fileDim objStream As FileStream = New FileStream( _strDownPath, FileMode.Open, FileAccess.Read)Dim objReader As B<strong>in</strong>aryReader = New B<strong>in</strong>aryReader(objStream)Dim bytes As Byte() = objReader.ReadBytes( _CType(objStream.Length, Integer))objReader.Close()objStream.Close()objClient.UploadData(strSource, "PUT", bytes)'Redirect back to <strong>in</strong>itial pageResponse.Redirect(strSource.Substr<strong>in</strong>g( _0, strSource.LastIndexOf("/")) & _"/Forms/AllItems.aspx")Creat<strong>in</strong>g the Feature.xml fileAs I stated earlier, the Worker.aspx page will be <strong>in</strong>voked from a new item on the document’sdrop-down menu. In order to create this new item, you’ll have to create a Feature.xml file torepresent the new feature. The Feature.xml file is straightforward and created <strong>in</strong> a mannerthat should be familiar to you by now.Follow these steps to create a Feature.xml file:1. In the Solution Explorer, right-click the WordCleaner project and select Add ➤ New Itemfrom the context menu.2. In the Add New Item dialog, select XML File.3. Name the XML file Feature.xml and click the Add button.4. Add the code from List<strong>in</strong>g 9-21 to create the Feature.xml file.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!