public static bool backupdata(string tipo) //datos o config { try { string[] AppArray = Application.ExecutablePath.Split('\\'); string ExeFile = AppArray[AppArray.Count() - 1]; DirectoryInfo backupdata = new DirectoryInfo(Environment.CurrentDirectory + @"\backupdata\"); string[] DateArray = DateTime.Now.ToShortDateString().Split('/'); string DateTimeHora = DateTime.Now.Hour.ToString(); string DateTimeMin = DateTime.Now.Minute.ToString(); string DateTimeSeg = DateTime.Now.Second.ToString(); string DateTimeNow = DateArray[2] + "-" + DateArray[1] + "-" + DateArray[0] + "-" + DateTimeHora + "-" + DateTimeMin + "-" + DateTimeSeg; if (!backupdata.Exists) { backupdata.Create(); // creo el directorio ARTICULOS } if (tipo == "datos") { //busco archivo y lo salvo sgdb.sdf File.Copy(Environment.CurrentDirectory + @"\sgdb.sdf", Environment.CurrentDirectory + @"\backupdata\" + DateTimeNow + @".sdf"); return(true); } else { if (tipo == "config") { //busco archivo y lo salvo App.config File.Copy(Environment.CurrentDirectory + @"\" + ExeFile + @".config", Environment.CurrentDirectory + @"\backupdata\" + DateTimeNow + @".config"); return(true); } else { return(false); } } } catch (Exception ex) { enviamail em = new enviamail(); // Porque el metodo es publico em.sendmail(ex, "Error: F-MDI-003"); return(false); } }