Share via


Read SSIS package programatically C#

 static void Main(string[] args)
        {
            Console.WriteLine();
            Application app = new Application();
            Package p;
            p = app.LoadPackage(@"C:\Users\pvenkat\Desktop\Original.dtsx", null);
            Executable e = (Executable)p;

            RecurseExecutables(e);
            Console.ReadKey();
        }

        public static void RecurseExecutables(Executable e)
        {
            //Console.WriteLine("Component : " + e.ToString());
            //Console.WriteLine(e.GetType());

            if (e is TaskHost)
            {
                TaskHost p = (TaskHost)e;
                Console.WriteLine(p.Name);

            }
            if (e is Package)
            {
                Package p = (Package)e;
                Console.WriteLine(p.Name);
                foreach (Executable pe in p.Executables)
                {
                    RecurseExecutables(pe);
                }
            }

            if (e is Sequence)
            {
                Sequence s = (Sequence)e;
                Console.WriteLine(s.Name);
                foreach (Executable pe in s.Executables)
                {
                    RecurseExecutables(pe);
                }
            }

        }