Exemplo n.º 1
0
	    private void BackupDataset(DataSet ds)
	    {
	        try
	        {
	            string filename = Executor.Instance.ParseIdString(Filename);
	            if (!string.IsNullOrEmpty(filename) && ds != null)
	            {
	                filename = AppDomain.CurrentDomain.BaseDirectory + filename;
	                if (File.Exists(filename))
	                {
	                    try
	                    {
	                        DateTime d = DateTime.Now;
	                        File.Move(filename,
	                                  string.Format("{0}_{1}-{2}-{3}_{4}-{5}-{6}-{7}.xml", filename.PathLastName(false),
	                                                d.Year, d.Month,
	                                                d.Day, d.Hour, d.Minute, d.Second, d.Millisecond));
	                    }
	                    catch (Exception ex)
	                    {
	                        ExceptionHandler.Handle(ex);
	                        try
	                        {
	                            File.Delete(filename);
	                        }
	                        catch (Exception e)
	                        {
	                            ExceptionHandler.Handle(e);
	                        }
	                    }
	                }
	                File.WriteAllText(filename, ds.ToXml());
	            }
	        }
	        catch (Exception ex)
	        {
	            ExceptionHandler.Handle(ex);
	        }
	    }