Exemplo n.º 1
0
 public MainWindow()
 {
     InitializeComponent();
     this.Visibility = Visibility.Hidden;
     UpdateGlassWindow c = new UpdateGlassWindow();
     c.Show();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Proceso de copiado de archivos temporales a carpeta de instalacion.
        /// </summary>
        private void inicieCopiado(string[] sourceFiles, UpdateGlassWindow win)
        {
            if (win.estado)
            {
                //Create a new instance of our ProgressBar Delegate that points
                // to the ProgressBar's SetValue method.
                UpdateProgressBarDelegate updatePbDelegate =
                    new UpdateProgressBarDelegate(pBar.SetValue);
                string carpetaInstalacion = System.Configuration.ConfigurationManager.AppSettings["CarpetaInstalacion"];
                string appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                string temporal = appData + "\\" + System.Configuration.ConfigurationManager.AppSettings["CarpetaLocalTemporal"] + "\\";
                foreach (string file in sourceFiles)
                {
                    //string nombreFile = file.Replace(temporal, "");
                    string nombreFile = file.Split('\\')[file.Split('\\').Length - 1];
                    /*String[] subFolds = nombreFile.Split('\\');
                    string acumSubFolder = string.Empty;

                    foreach (string subFold in subFolds)
                    {
                        acumSubFolder += subFold + "\\";

                        if (!Directory.Exists(carpetaInstalacion + "\\" + acumSubFolder.Substring(0, acumSubFolder.Length-2)))
                        {
                            Directory.CreateDirectory(carpetaInstalacion + "\\" + acumSubFolder.Substring(0, acumSubFolder.Length - 2));
                        }
                    }*/

                    this.addText("Copiando archivo: " + file + "\n");
                    try
                    {
                        System.IO.File.Copy(file, carpetaInstalacion + "\\" + nombreFile, true);
                        actualFiles++;
                    }
                    catch (Exception ex)
                    {
                        if (!file.Contains("Fluid"))
                        {
                            win.addText("Ocurrió un error en el copiado de " + file + "\n" + ex.Message);
                            throw (ex);
                        }
                        else if (file.Contains("Fluid"))
                        {
                            actualFiles++;
                            //Expected error
                        }
                    }
                    this.actualizarLbCuenta();
                    try
                    {
                        //System.Threading.Thread.Sleep(500);
                        Dispatcher.Invoke(updatePbDelegate,
                        System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, Convert.ToDouble(actualFiles) });
                    }
                    catch (Exception)
                    {
                        //System.Console.Write(e.Message);
                    }
                    if (!win.estado)
                        break;
                }
            }
        }