static void Main(string[] args) { WriteData writeData = new WriteData("filename.txt"); //do something writeData.Dispose(); }