Exemplo n.º 1
0
        public override void CopyFile(FileDataInfo file)
        {
            CurrentFile = file;
            Reader      = file.GetStreamToRead();
            Writer      = file.GetStreamToWrite(FileMode.Create);
            var writer1 = new BinaryWriter(Writer);

            readBytes            = 0;
            FileBytesTransferred = 0;

            unsafe
            {
                do
                {
                    //Dinamic bufferSize. Dynamic buffer size.
                    readBytes = Reader.Read(buffer, 0, (int)(file.Size > BufferSize ? BufferSize : file.Size));
                    writer1.Write(buffer, 0, readBytes);

                    //Status
                    FileBytesTransferred  += readBytes;
                    TotalBytesTransferred += readBytes;
                } while (readBytes > 0);
            }

            Reader.Close();
            Reader.Dispose();

            Writer.Flush();
            Writer.Close();
            Writer.Dispose();
        }
Exemplo n.º 2
0
        public override void CopyFile(FileDataInfo file)
        {
            CurrentFile = file;
            var    driverInfo = new System.IO.DriveInfo(Delimon.Win32.IO.Path.GetPathRoot(file.DestinyPath));
            string tmp_file   = "";

            using (Reader = file.GetStreamToRead())
            {
                if (file.DestinyPath.Length > 248)
                {
                    //Create the file in short name
                    tmp_file = Delimon.Win32.IO.Path.Combine(file.DestinyDirectoryPath, "tmp_a19");

                    using (Writer = new FileStream(tmp_file, FileMode.Create, FileAccess.Write))
                    {
                        //if (driverInfo.DriveType == DriveType.Removable)
                        //{
                        //    ExecuteCopySafe(driverInfo, file);
                        //}
                        //else ExecuteCopy(driverInfo, file);
                        ExecuteCopy(driverInfo, file);
                    }

                    //Move the file to it's original destinyPath
                    if (Delimon.Win32.IO.File.Exists(file.DestinyPath))
                    {
                        Delimon.Win32.IO.File.Delete(file.DestinyPath);
                    }
                    Delimon.Win32.IO.File.Move(tmp_file, file.DestinyPath);
                }
                else
                {
                    using (Writer = file.GetStreamToWrite(FileMode.Create))
                    {
                        //if (driverInfo.DriveType == DriveType.Removable && driverInfo.DriveFormat=="FAT32")
                        //{
                        //    ExecuteCopySafe(driverInfo, file);
                        //}
                        //else ExecuteCopy(driverInfo, file);

                        ExecuteCopy(driverInfo, file);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public override void CopyFile(FileDataInfo file)
        {
            CurrentFile = file;
            fileName    = Delimon.Win32.IO.Path.GetPathRoot(file.DestinyPath);

            driverInfo = new Alphaleonis.Win32.Filesystem.DriveInfo(fileName);

            using (Reader = file.GetStreamToRead())
            {
                using (Writer = file.GetStreamToWrite(FileMode.Create))
                {
                    //if (driverInfo.DriveType == DriveType.Removable && driverInfo.DriveFormat=="FAT32")
                    //{
                    //    ExecuteCopySafe(driverInfo, file);
                    //}
                    //else ExecuteCopy(driverInfo, file);

                    ExecuteCopy(driverInfo, file);
                }
                //}
            }
        }
Exemplo n.º 4
0
        void Consumer_WriteBytes(FileDataInfo file)
        {
            Buffer_Length bl;
            var           writer = file.GetStreamToWrite(FileMode.Create);

            while (!(queve.Count == 0 && producerFinish))
            {
                if (queve.Count > 0)
                {
                    lock (thisobject)
                    {
                        bl = queve.Dequeue();
                    }

                    writer.Write(bl.buffer, 0, bl.length);
                    FileBytesTransferred  += bl.length;
                    TotalBytesTransferred += bl.length;
                }
            }

            finish = true;
        }
Exemplo n.º 5
0
        public override void CopyFile(FileDataInfo file)
        {
            CurrentFile = file;
            Reader      = file.GetStreamToRead();

            using (Writer = file.GetStreamToWrite(FileMode.Create))
            {
                readBytes            = 0;
                FileBytesTransferred = 0;

                while ((readBytes = Reader.Read(buffer, 0, BufferSize)) > 0)
                {
                    Writer.SetLength(Writer.Length + readBytes);

                    Writer.Write(buffer, 0, readBytes);

                    //Status
                    FileBytesTransferred  += readBytes;
                    TotalBytesTransferred += readBytes;
                }
            }

            Reader.Dispose();
        }