Dealing with the “TempFileIsBeingCreated” Event
This sample illustrates how to create a callback that can be used to handle the “TempFileIsBeingCreated” event.
Being able to deal with this event may be necessary to placate over-zealous anti-virus software.
C#
C++
VB.Net
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | public void SetupCallBack() { Func< string , bool > callback = TempFileIsAboutToBeCreated; SolidFramework.SolidEnvironment.SetTempFileIsAboutToBeCreated(callback); } private bool TempFileIsAboutToBeCreated( string fileCreated) { // Do whatever processing is needed at this point // For example record the name of the file being created // System.Diagnostics.Debug.WriteLine(fileCreated); // Or incrementing the number of files // total++; // Or adding the filename to a list of files // files.Add(fileCreated); // Returning true allows the file to be created. Returning false will prevent file creation // which will probably cause the conversion to fail. return true ; } |
C++
1 2 3 | //Create an anonymous function to record the file name SolidEnvironment.SetTempFileIsAboutToBeCreated{ Console.WriteLine(path); return true ; }); |
VB.Net
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Public Sub SetupCallBack() Dim callback As Func(Of String , Boolean ) = AddressOf TempFileIsAboutToBeCreated SolidFramework.SolidEnvironment.SetTempFileIsAboutToBeCreated(callback) End Sub Private Function TempFileIsAboutToBeCreated(fileCreated As String ) As Boolean ' Do whatever processing is needed at this point ' For example record the name of the file being created ' System.Diagnostics.Debug.WriteLine(fileCreated); ' Or incrementing the number of files ' total++; ' Or adding the filename to a list of files ' files.Add(fileCreated); ' Returning true allows the file to be created. Returning false will prevent file creation ' which will probably cause the conversion to fail. Return True End Function |