Esempio n. 1
0
        private static void RemoveDlls(FileInfo[] dlls, ref string log)
        {
            System.IO.DirectoryInfo destDir = null;

            if (!System.IO.Directory.Exists(Global.DestPath))
            {
                MessageBox.Show(form, "Deployment directory not found!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw new System.IO.DirectoryNotFoundException();
            }
            else
            {
                destDir = System.IO.Directory.CreateDirectory(Global.DestPath);
                System.IO.Directory.SetCurrentDirectory(destDir.FullName);
            }

            for (int i = 0; i < dlls.Length; ++i)
            {
                if (System.IO.File.Exists(dlls[i].name))
                {
                    System.IO.File.Delete(dlls[i].name);
                    log += destDir.FullName + dlls[i].name + " removed" + Environment.NewLine + Environment.NewLine;
                }
            }

            System.IO.Directory.SetCurrentDirectory(Global.currentWorkingDir);
        }
Esempio n. 2
0
        private static void DeployDlls(FileInfo[] dlls, ref string log)
        {
            System.IO.DirectoryInfo baseDir = null;
            System.IO.DirectoryInfo srcDir = null;
            System.IO.DirectoryInfo destDir = null;

            bool existBaseDllPath = true;

            if (Global.Debug)
            {
                if (!System.IO.Directory.Exists(Global.DebugBaseDllPath))
                    existBaseDllPath = false;
                else
                    baseDir = System.IO.Directory.CreateDirectory(Global.DebugBaseDllPath);
            }
            else
            {
                if (!System.IO.Directory.Exists(Global.ReleaseBaseDllPath))
                    existBaseDllPath = false;
                else
                    baseDir = System.IO.Directory.CreateDirectory(Global.ReleaseBaseDllPath);
            }

            if (!existBaseDllPath)
            {
                MessageBox.Show(form, "Base Directory not found!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw new System.IO.DirectoryNotFoundException() ;
            }

            if (System.IO.Directory.Exists(Global.SrcDllPath))
            {
                srcDir = System.IO.Directory.CreateDirectory(Global.SrcDllPath);
            }

            if (!System.IO.Directory.Exists(Global.DestPath))
            {
                MessageBox.Show(form, "Deployment directory not found!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw new System.IO.DirectoryNotFoundException();
            }
            else
            {
                destDir = System.IO.Directory.CreateDirectory(Global.DestPath);
                System.IO.Directory.SetCurrentDirectory(destDir.FullName);
            }

            string fullFilePath = null;

            for (int i = 0; i < dlls.Length; ++i)
            {
                if (dlls[i].isBase)
                    fullFilePath = baseDir.FullName + dlls[i].name;
                else if (srcDir == null)
                {
                    MessageBox.Show(form, "File " + dlls[i].name + " not found!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }
                else
                    fullFilePath = srcDir.FullName + dlls[i].name;

                if (!System.IO.File.Exists(fullFilePath))
                {
                    MessageBox.Show(form, "File " + dlls[i].name + " not found!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }

                if (!System.IO.File.Exists(dlls[i].name))
                {
                    System.IO.File.Copy(fullFilePath, dlls[i].name);
                    log += destDir.FullName + dlls[i].name + " copied" + Environment.NewLine + Environment.NewLine;
                }
                else
                    log += destDir.FullName + dlls[i].name + " already exists" + Environment.NewLine + Environment.NewLine;
            }

            System.IO.Directory.SetCurrentDirectory(Global.currentWorkingDir);
        }