Insert logs into Local Drive

Insert logs into Local Drive :

System.IO.StreamWriter Class

Assembly: Mscorlib.dll
Namespace: System.IO

Stream Writer :    StreamWriter sw = new StreamWriter(str, true)

Initializes a new instance of the Stream Writer class for the specified file by using the default encoding and buffer size. If the file exists, it can be either overwritten or appended to. If the file does not exist, this constructor creates a new file.

Using :  The using statements in the examples open and prepare the files. At the end of the statements they close and dispose of the resources.

using System;
using System.IO;

public class Logger
public Logger()

public void Write(string Message)
DirectoryInfo directoryInfo;

string str; string FileWrite;

FileWrite = “Y”;
str = “C:\\Log\\”;

if (!FileWrite.StartsWith(“Y”)) return;

if (!Directory.Exists(str))
directoryInfo = Directory.CreateDirectory(str);

str = str + “BaluGajjalaLogs” + DateTime.Now.ToString(“yyyyMMdd”) + “.log”;

//StreamWriter sw = new StreamWriter(“copy.txt”, true); //append
//StreamWriter sw = new StreamWriter(“copy.txt”, false); //overwrite

using (StreamWriter sw = new StreamWriter(str, true))
sw.WriteLine(string.Format(“{0}”, Message));
catch (Exception ex)
System.Diagnostics.Trace.WriteLine(“Error in Logging<br/> Stack Trace: ” + ex.StackTrace + “<br/> Error Message: ” + ex.Message);

Enjoy 🙂


Hide FormSelector

Hide FormSelector :

Sometimes will get the requirement to hide the from selector.

If an entity has one or more multiple forms then we need to hide the from selector. Paste the below code in form load. It will work.

This code is Microsoft unsupported code but still, it will work.

function hideformselector(){

document.getElementById(“formselectorcontainer”).style.display = “none”;


That’s It. Enjoy 🙂