class MethodLog { //This method is used for calculating method time in each class. public void GetMethodLog(string clsname , string methodname , int lineno , string description , string methodstarttime , string methodendtime) { // get the base directory string baseDir = AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.RelativeSearchPath; // search the file below the current directory string retFilePath = baseDir + "//" + "LogFile.txt"; // Create a writer and open the file: StreamWriter log; if (!File.Exists(retFilePath)) { log = new StreamWriter(retFilePath); } else { log = File.AppendText(retFilePath); } string strclsname = "Class Name : " + clsname ; string strmethodname = "Method Name : " + methodname ; string strlineno = "Line Number : " + lineno ; string strdescription = "Method Description :" + description ; string strmethodstarttime = "Method Start Time :" + methodstarttime ; string strmethodendtime = "Method End Time :" + methodendtime ; string eol = "^^---------------------------------------------------------^^"; // Write log entries to the file: log.WriteLine(strclsname); log.WriteLine(strmethodname); log.WriteLine(strlineno); log.WriteLine(strdescription); log.WriteLine(strmethodstarttime); log.WriteLine(strmethodendtime); log.WriteLine(eol); // Close the stream: log.Close(); } }