internal static string IsValidPath(string[] args) { var argsSourceDbPath = string.Empty; //SI le chemin n'es pas passé en arguments, on génère une rreur dans le log. if (args == null || args.Length == 0) { Display.errorMessage("L'outil de conversion ne contient pas d'arguments."); } else { var argument = args[0]; if (!string.IsNullOrEmpty(argument) && pathFileExist(argument) && pathEqualsExtension(argument, ".mdb")) { argsSourceDbPath = argument; Display.successMessage(message, true); } else { Display.errorMessage(errorMessage); } } return(argsSourceDbPath); }
public bool setupDriver() { try { Process process = Process.Start(Const.DRIVER_PATH_MSI, "/q"); while (!process.HasExited) { Display.infosMessage("Installation du pilote Access Database Engine 2010...", true); Thread.Sleep(250); } } catch (Exception ex) { Display.errorMessage("L'installation du pilote Access Database Engine 2010 a échoué (" + ex.Message + ")", true); return(false); } Display.successMessage("Installation du pilote Access Database Engine 2010 est Terminée", true); return(true); }
public bool convert(string SourceDb) { bool flag = false; string path = this.getdestFile(SourceDb); try { if (File.Exists(path)) { File.Delete(path); } object[] args = new object[2] { (object)SourceDb, (object)path }; Display.infosMessage("Conversion de la base de données en cours...", true); object instance = Activator.CreateInstance(Type.GetTypeFromProgID(Const.DRIVER_NAME)); instance.GetType().InvokeMember(Const.COMPACT_DATABASE, BindingFlags.InvokeMethod, (Binder)null, instance, args); Marshal.ReleaseComObject(instance); Display.successMessage("La base a été correctement convertie ! ", true); Display.foreground(ConsoleColor.White); Console.WriteLine("BASE SOURCE : " + Environment.NewLine); Console.WriteLine(SourceDb ?? ""); Display.newLines(1); Console.WriteLine("BASE CONVERTIE : " + Environment.NewLine); Console.WriteLine(path ?? ""); Thread.Sleep(5000); Environment.Exit(0); } catch (Exception ex) { Display.errorMessage("Une erreur s'est produite lors de la conversion : " + ex.Message, true); } return(flag); }