private void WriteMessageToFile(string filepath, string message)
{
StreamWriter sw = null;
try
{
sw = new StreamWriter("some file path"filepath, true);
sw.WriteLine("some string"message);
sw.Flush();
sw.Close();
catch (Exception ex)
{
throw ex;
}
}
Caveat
However, writing your own logging framework from scratch (with no knowledge of other frameworkexisting frameworks) can be rewarding in and of itself as a training exercise.
Based on your code, I surmise that you are a beginner, at least to creating reusable libraries. So if writing this library benefits you for training purposes, don't let my review stop you.
But
But if your only goal is to create a functionally usable tool, then I do suggest first looking for existing solutions, either to already solve your problem or even just to get some inspiration/ideas.