Exemplo n.º 1
0
        protected override void _Partir(string fichero,string sal1, string dir, long kb)
        {
            InfoEFS info = new InfoEFS();
            // Calcular el numero de fragmentos
            long tamano = new FileInfo (fichero).Length;
            long tFragmento = kb * 1024;

            info.NombreOriginal = new FileInfo(fichero).Name;
            info.TotalFragmentos = (int) Math.Ceiling ((double) tamano / (double) tFragmento);

            string formato = new FileInfo (fichero).Name;
            formato = dir + Path.DirectorySeparatorChar + formato;
            formato += "." + info.TotalFragmentos + "_{0}";
            long transferidos = 0;
            info.Fragmento = 1;
            do{
                string dest = string.Format (formato, info.Fragmento);
                UtilidadesFicheros.ComprobarSobreescribir (dest);
                transferidos += UtilidadesFicheros.CopiarIntervalo
                        (fichero, dest, transferidos, tFragmento);
                info.Fragmento++;
                OnProgress (transferidos, tamano);

            }while (transferidos < tamano);
        }
Exemplo n.º 2
0
        public override bool PuedeUnir(string fichero)
        {
            if (! File.Exists(fichero) )
                return false;

            try {
                InfoEFS i = new InfoEFS (fichero);
                return (i.Fragmento == 1);
            }
            catch (Exception)
            {
                return false;
            }
        }
Exemplo n.º 3
0
        protected override void _Unir(string fichero, string dirDest)
        {
            InfoEFS info = new InfoEFS (fichero);
            string original = dirDest + Path.DirectorySeparatorChar +
                    info.NombreOriginal;
            UtilidadesFicheros.ComprobarSobreescribir (original);
            OnProgress (0, info.TotalFragmentos);

            for (int i=1; i <= info.TotalFragmentos; i++){
                info.Fragmento = i;
                string source = dirDest + Path.DirectorySeparatorChar + info.ToString();
                if (!File.Exists (source)){
                    throw new System.IO.FileNotFoundException("", source);
                }
                UtilidadesFicheros.CopiarTodo (source, original);
                OnProgress (i, info.TotalFragmentos);
            }
        }