Create application log file in C# / Write to File example

Application log file example
private string logFile = "full path and file name (C:\\temp\\MyApplicationLog.txt)";
...
WriteToLogFile("your application message", logFile); // use any time to add record to the log file
...
public void WriteToLogFile(string strMessage, string outputFile)
{
   string line = DateTime.Now.ToString() + " | ";
   line += strMessage;
   FileStream fs = new FileStream(outputFile, FileMode.Append, FileAccess.Write, FileShare.None);
   StreamWriter swFromFileStream = new StreamWriter(fs);
   swFromFileStream.WriteLine(line);
   swFromFileStream.Flush();
   swFromFileStream.Close();
}


|
2014/10/19 08:55

SmartMarine 3D - Get list of deleted objects by user, date and time

| |

DB platform: MS SQL server

Product: SmartMarine 3D, SmartPlant 3D (SM3D, SP3D)

Task: Get list of deleted objects by specific user or/and on specific date and time

A list of the deleted objects is avalable from project's Reports database ( xxxx_RDB ).

2013/12/09 14:48

SmartMarine 3D - Show recent objects in the work space

| | | |

Database platform: MS SQL server Product: SmartMarine 3D, SmartPlant 3D (SM3D, SP3D) Task: Show in the work space all objects created or edited recently For troubleshooting and for monitoring purposes it is useful sometimes not only to get a list of the objects created or edited recently, but also to show these objects in the work space.

2013/12/09 14:48

C# Is the Logged User a member of specific Windows Domain Group?

C sharp code
using System.DirectoryServices.AccountManagement;
string userName = SystemInformation.UserName;
string UDN = SystemInformation.UserDomainName;
string domainUser = UDN + "\\" + userName;
PrincipalContext pc = new PrincipalContext(ContextType.Domain);
UserPrincipal user = UserPrincipal.FindByIdentity(pc, IdentityType.SamAccountName, domainUser);
GroupPrincipal group = GroupPrincipal.FindByIdentity(pc, "Domain_Group_Name");
bool is_member = user.IsMemberOf(group);

|
2013/10/19 11:10

Remote Desktop microphone redirection

Install and configure the microphone on the local PC and set redirection at Remote Desktop Connection 

Remote Desktop Connection microphone redirection



Allow audio recording at hostHKLM\SYSTEM\CurrentControlSet\Con
| |
2013/10/19 08:48

The Marine Design Forum discontinued

15 January 2013

Due to Tribon (M1, M2, M3) software retirement, the Tribon related marine design forum support has been discontinued.


|
2013/01/15 18:55