public static void LoadScripts() { BusinessLogicLayer objBusiness = new BusinessLogicLayer(); LogFileHelper logger = new LogFileHelper(); try { Console.WriteLine("Enter the file Path"); //string path = @"D:\AccionLabs\Help\LocalDB\Functions"; var path = Console.ReadLine(); foreach (string fileName in Directory.GetFiles(path)) { //CHECK FOR EXTENSION - .SQL string ext = Path.GetExtension(fileName); //GET EACH FILE if (ext.ToUpper() == (".sql").ToUpper()) { var fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) { string functionContent = streamReader.ReadToEnd(); if (!string.IsNullOrEmpty(functionContent)) { //SEND FILENAME AND FILECONTENT FOR EACH FILE objBusiness.CreateFunctionfromFile(fileName, functionContent); } } } } EnterChoice(); } catch (Exception ex) { logger.WriteToFile("LoadScripts method exception : " + ex.Message); } }