Click or drag to resize

IDocumentReplaceFile Method

ReplaceFile - archive the file provided and update record if necessary, or replace contents of existing file with same name, or

There are three different scenarios:

  • The document record exists but filename is empty. The file is saved and the document record is updated with files name

  • The document record exists but not the file. File is saved with name from document record.

  • The document record and file exists. If the content of the files differs the existing content is

Namespace:  SuperOffice.COM.SuperOfficeDB
Assembly:  SuperOfficeDB.Interop (in SuperOfficeDB.Interop.dll) Version: 8.0.0.0
Syntax
void ReplaceFile(
	string bstrFilePath,
	bool deleteFilePath = false
)

Parameters

bstrFilePath
Type: SystemString
path to the file you want to archive
deleteFilePath (Optional)
Type: SystemBoolean
remove the original once the file is archived, true if it should be deleted
Examples

ReplaceFile

This text may be copied to the notepad, and saved as a *.vbs file. Remember to change the login information. You also need two different files, with different text to verify. The examples use c:\test.doc and c:\test2.doc

VB
Dim objDB, objApp, soDoc
Set objDB = CreateObject("SuperOfficeDB.Database")
Set objApp = CreateObject("SuperOffice.Application")

objDB.Login objApp.Database.Username, objApp.Database.Password
Set soDoc = objDB.CreateDocument
soDoc.SetDefaults
soDoc.Contact = objDB.GetContact(2)
soDoc.Header = "Added though SuperCOM"
soDoc.Save

objApp.database.Refresh
objApp.SetContext 2, 0, 0
MsgBox "Check for the added document with header Added through SuperCOM, try to open." & vbCrLf & "It fails since we have not yet created a document file."

soDoc.ReplaceFile "c:\test.doc", False
soDoc.Save
objApp.database.Refresh
MsgBox "Now try to open the file"

soDoc.ReplaceFile "c:\test2.doc", False
soDoc.Save
objApp.database.Refresh
MsgBox "Now try to open the file, verify that the text is replaced."

See Also