コード例 #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();
        }
コード例 #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);
                    }
                }
            }
        }
コード例 #3
0
        void Producer_ReadBytes(FileDataInfo file)
        {
            int length = 0;
            var reader = file.GetStreamToRead();

            while (reader.Position < reader.Length)
            {
                if (queve.Count < buffersListCapacity)
                {
                    lock (thisobject)
                    {
                        buffer = new byte[BufferSize];
                        length = reader.Read(buffer, 0, BufferSize);
                        queve.Enqueue(new Buffer_Length(buffer, length));
                    }
                }
            }

            producerFinish = true;
        }
コード例 #4
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);
                }
                //}
            }
        }
コード例 #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();
        }