BKI_DichVuMatDat.WinFormControls.openTemplate C# (CSharp) Method

openTemplate() public static method

public static openTemplate ( string ip_file_name ) : void
ip_file_name string
return void
        public static void openTemplate(string ip_file_name)
        {
            string sourcePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"Template";//Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Template\");
            string targetPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string sourceFile = System.IO.Path.Combine(sourcePath, ip_file_name);
            string destFile = System.IO.Path.Combine(targetPath, ip_file_name);
            if (!System.IO.Directory.Exists(targetPath))
            {
                System.IO.Directory.CreateDirectory(targetPath);
            }
            System.IO.File.Copy(sourceFile, destFile, true);

            string newpath = targetPath + "\\" + ip_file_name;

            var excel = new Excel.Application();
            excel.Visible = true;
            Excel.Workbooks books = excel.Workbooks;
            Excel.Workbook openexcel = books.Open(newpath);
        }