I am creating a plugin for Revit that registers several events within its application.
For every time an event happens, a line is writen on a txt file telling me about the event such as:
The user opened a document on Autodesk Revit 2019 (...)
I am obtaining the "Autodesk Revit 2019" (name of application) by getting the name of the MainWindowTitle of the application like so: Process.GetCurrentProcess().MainWindowTitle
I would like to attribute a name to this string (although I know that this is not exacly a string, but that it gets some characters that spell words).
I have been trying:
public static string originalString = Process.GetCurrentProcess().MainWindowTitle;
(...)
Trace.WriteLine("O utilizador " + Environment.UserName + " abriu um documento no " + originalString + " a " + DateTime.Now + " (DocumentOpenedEventArgs)");
Which writes in the txt file:
O utilizador rita.aguiar abriu o a 20/09/2018 10:36:42 (ApplicationInitializedEventArgs)
See attached pngs for more information.
As you can read, it did not write on the txt file "Autodesk Revit 2019 - [Home]" as I hoped for.
If I had writen Process.GetCurrentProcess().MainWindowTitle directly on the Trace.WriteLine I would have obtained "Autodesk Revit 2019 - [Home]", but I wish to write an assigned name instead.
How to successfully write "Autodesk Revit 2019 - [Home]" by assigning a name to Process.GetCurrentProcess().MainWindowTitle?
Later I would like to obtain this name by insted getting just Autodesk Revit 2019 like so:
public static string originalString = Process.GetCurrentProcess().MainWindowTitle;
public static string[] splittedString = originalString.Split("-".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
public static string AppName = splittedString[0];
Any help would be appretiated!
For every time an event happens, a line is writen on a txt file telling me about the event such as:
The user opened a document on Autodesk Revit 2019 (...)
I am obtaining the "Autodesk Revit 2019" (name of application) by getting the name of the MainWindowTitle of the application like so: Process.GetCurrentProcess().MainWindowTitle
I would like to attribute a name to this string (although I know that this is not exacly a string, but that it gets some characters that spell words).
I have been trying:
public static string originalString = Process.GetCurrentProcess().MainWindowTitle;
(...)
Trace.WriteLine("O utilizador " + Environment.UserName + " abriu um documento no " + originalString + " a " + DateTime.Now + " (DocumentOpenedEventArgs)");
Which writes in the txt file:
O utilizador rita.aguiar abriu o a 20/09/2018 10:36:42 (ApplicationInitializedEventArgs)
See attached pngs for more information.
As you can read, it did not write on the txt file "Autodesk Revit 2019 - [Home]" as I hoped for.
If I had writen Process.GetCurrentProcess().MainWindowTitle directly on the Trace.WriteLine I would have obtained "Autodesk Revit 2019 - [Home]", but I wish to write an assigned name instead.
How to successfully write "Autodesk Revit 2019 - [Home]" by assigning a name to Process.GetCurrentProcess().MainWindowTitle?
Later I would like to obtain this name by insted getting just Autodesk Revit 2019 like so:
public static string originalString = Process.GetCurrentProcess().MainWindowTitle;
public static string[] splittedString = originalString.Split("-".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
public static string AppName = splittedString[0];
Any help would be appretiated!
Comment