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#

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++
 
//Create an anonymous function to record the file name

SolidEnvironment.SetTempFileIsAboutToBeCreated{ Console.WriteLine(path); return true; });

VB.Net
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