Save configuration / recording

There are two possibilities to save:

The difference is that the .svdx file can be opened in any TwinCAT 3 Scope View, in order to display the measured data. The .tcscopex file, on the other hand, only contains the configuration, without measured data. It can be used to start new recordings, as required.

private void btnSave_Click(object sender, EventArgs e)
{
  try
  {
    //save data and configuration
    if (scopeProjectPanel.ScopeProject.ScopeState == TwinCAT.Measurement.Scope.API.ScopeViewState.Reply)
    {
      File.Create("ExportData.svdx").Close();
      scopeProjectPanel.ScopeProject.SaveData("ExportData.svdx");
    }
    //just save the configuration
    else
    {
      File.Create(filename).Close();
      scopeProjectPanel.ScopeProject.SaveToFile(filename);
    }
  }
  catch (Exception err)
  {
    MessageBox.Show(this, err.Message, "Error on save!",MessageBoxButtons.OK, MessageBoxIcon.Error);
  }
}