ToString() публичный Метод

public ToString ( ) : string
Результат string
Пример #1
0
        public static int Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("usage: makeiso [drive] [file]");
                return 1;
            }

            var drive = new DriveInfo(args[0]);

            if (drive.DriveType != DriveType.CDRom)
            {
                Console.Error.WriteLine("Invalid drive letter.");
                return 2;
            }

            try
            {
                using (var inputFileHandle = CreateFile(@"\\.\" + drive.ToString().TrimEnd('\\'), GENERIC_READ, FILE_SHARE_READ, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0))
                {
                    if (inputFileHandle.IsInvalid)
                    {
                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    }

                    using (var inputStream = new FileStream(inputFileHandle, FileAccess.Read))
                    {
                        using (var outputStream = new FileStream(args[1], FileMode.CreateNew))
                        {
                            inputStream.CopyTo(outputStream);
                        }
                    }
                }

                return 0;
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                return 1;
            }
        }
Пример #2
0
        public static string GetDeviceFromDrive(System.IO.DriveInfo driveInfo)
        {
            IntPtr         pStorageDeviceNumber = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(STORAGE_DEVICE_NUMBER)));
            SafeFileHandle hDrive = null;

            try {
                string driveName = "\\\\.\\" + driveInfo.ToString().Substring(0, 2);
                hDrive = ApiFunctions.CreateFile(driveName, AccessMask.GENERIC_READ,
                                                 System.IO.FileShare.ReadWrite, 0, System.IO.FileMode.Open, 0, IntPtr.Zero);

                if (hDrive.IsInvalid)
                {
                    throw new FileLoadException("Drive handle invalid");
                }

                bool status;
                int  retByte;
                System.Threading.NativeOverlapped nativeOverlap = new System.Threading.NativeOverlapped();
                status = ApiFunctions.DeviceIoControl(hDrive, DeviceIOControlCode.StorageGetDeviceNumber, IntPtr.Zero, 0,
                                                      pStorageDeviceNumber, Marshal.SizeOf(typeof(STORAGE_DEVICE_NUMBER)), out retByte, ref nativeOverlap);

                if (!status)
                {
                    throw new FileLoadException("DeviceIoControl error");
                }

                STORAGE_DEVICE_NUMBER storDevNum = (STORAGE_DEVICE_NUMBER)Marshal.PtrToStructure(pStorageDeviceNumber, typeof(STORAGE_DEVICE_NUMBER));

                return("\\\\.\\PhysicalDrive" + storDevNum.DeviceNumber);
            }
            finally {
                Marshal.FreeHGlobal(pStorageDeviceNumber);
                if (hDrive != null)
                {
                    hDrive.Close();
                }
            }
        }
        /// <summary>
        /// Generates <see cref="TreeViewItem"/> for drive info.
        /// </summary>
        /// <param name="drive"></param>
        /// <returns></returns>
        private static TreeViewItem GenerateDriveNode(DriveInfo drive)
        {
            var item = new TreeViewItem
            {
                Tag = drive,
                Header = drive.ToString()
            };

            item.Items.Add("*");
            return item;
        }
Пример #4
0
 public bool Do(DriveInfo drive)
 {
     bool result = true;
     foreach (CopyJob cj in jobs)
     {
         result = result & cj.Do(drive.ToString());
         if (pb.Value == pb.Maximum)
             pb.Value = 1;
         pb.Value++;
     }
     return result;
 }
Пример #5
0
        public void TestInvalidDiskProperties()
        {
            string invalidDriveName = GetInvalidDriveLettersOnMachine().First().ToString();
            var invalidDrive = new DriveInfo(invalidDriveName);

            Assert.Throws<DriveNotFoundException>(() => invalidDrive.AvailableFreeSpace);
            Assert.Throws<DriveNotFoundException>(() => invalidDrive.DriveFormat);
            Assert.Equal(DriveType.NoRootDirectory, invalidDrive.DriveType);
            Assert.False(invalidDrive.IsReady);
            Assert.Equal(invalidDriveName + ":\\", invalidDrive.Name);
            Assert.Equal(invalidDriveName + ":\\", invalidDrive.ToString());
            Assert.Equal(invalidDriveName + ":\\", invalidDrive.RootDirectory.FullName);
            Assert.Throws<DriveNotFoundException>(() => invalidDrive.TotalFreeSpace);
            Assert.Throws<DriveNotFoundException>(() => invalidDrive.TotalSize);
            Assert.Throws<DriveNotFoundException>(() => invalidDrive.VolumeLabel);
            Assert.Throws<DriveNotFoundException>(() => invalidDrive.VolumeLabel = null);
        }
Пример #6
0
        /// <summary>
        /// The encrypted file by AES (exactly Rijndael) to the original file or folder by user's password.
        /// ユーザーが設定したパスワードによって、AES(正確にはRijndael)によって暗号化されたファイルを
        /// 元のファイル、またはフォルダーに復号して戻す。
        /// </summary>
        /// <param name="FilePath">File path or directory path is encrypted</param>
        /// <param name="OutFileDir">The directory of outputing encryption file.</param>
        /// <param name="Password">Encription password string</param>
        /// <returns>bool true: Success, false: Failed</returns>
        public bool Decrypt(
      object sender, DoWorkEventArgs e,
      string FilePath, string OutDirPath, string Password, byte[] PasswordBinary, Action<int, string> dialog)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
              worker.WorkerSupportsCancellation = true;

              //-----------------------------------
              // Header data is starting.
              // Progress event handler
              ArrayList MessageList = new ArrayList();
              MessageList.Add(READY_FOR_DECRYPT);
              MessageList.Add(Path.GetFileName(FilePath));
              worker.ReportProgress(0, MessageList);

              int len = 0;
              byte[] byteArray;

              List<string> FileList = new List<string>();
              Dictionary<int, FileListData> dic = new Dictionary<int, FileListData>();

              if (_TokenStr.Trim() == "_AttacheCaseData")
              {
            // Atc data
              }
              else if (_TokenStr.Trim() == "_Atc_Broken_Data")
              {
            // Atc file is broken
            e.Result = new FileDecryptReturnVal(ATC_BROKEN_DATA, FilePath);
            return (false);
              }
              else
              {
            // not AttacheCase data
            e.Result = new FileDecryptReturnVal(NOT_ATC_DATA, FilePath);
            return(false);
              }

              Rfc2898DeriveBytes deriveBytes;
              if (PasswordBinary == null)
              {
            deriveBytes = new Rfc2898DeriveBytes(Password, _salt, 1000);
              }
              else
              {
            deriveBytes = new Rfc2898DeriveBytes(PasswordBinary, _salt, 1000);
              }

              byte[] key = deriveBytes.GetBytes(32);
              byte[] iv = deriveBytes.GetBytes(32);

              using (FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
              {
            if (fs.Length < 32)
            {
              // not AttacheCase data
              e.Result = new FileDecryptReturnVal(NOT_ATC_DATA, FilePath);
              return (false);
            }
            else
            {
              if (_ExeOutSize > 0)
              {
            // self-executable file
            fs.Seek(_ExeOutSize + 36, SeekOrigin.Begin);
              }
              else
              {
            fs.Seek(36, SeekOrigin.Begin);
              }
            }

            try
            {
              // The Header of MemoryStream is encrypted
              using (Rijndael aes = new RijndaelManaged())
              {
            aes.BlockSize = 256;             // BlockSize = 32 bytes
            aes.KeySize = 256;               // KeySize = 32 bytes
            aes.Mode = CipherMode.CBC;       // CBC mode
            aes.Padding = PaddingMode.Zeros; // Padding mode is "ZEROS".

            aes.Key = key;
            aes.IV = iv;

            // Decryption interface.
            ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
            using (CryptoStream cse = new CryptoStream(fs, decryptor, CryptoStreamMode.Read))
            {
              using (MemoryStream ms = new MemoryStream())
              {
                byteArray = new byte[_AtcHeaderSize];
                len = cse.Read(byteArray, 0, _AtcHeaderSize);
                ms.Write(byteArray, 0, _AtcHeaderSize);
            #if (DEBUG)
                //string AppDirPath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
                string DesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                string TempFilePath = Path.Combine(DesktopPath, "decrypt_header.txt");
                using (StreamWriter sw = new StreamWriter(TempFilePath, false, Encoding.UTF8))
                {
                  sw.Write(Encoding.UTF8.GetString(byteArray));
                }
            #endif
                // Check Password Token
                if (Encoding.UTF8.GetString(byteArray).IndexOf(AtC_ENCRYPTED_TOKEN) > -1)
                {
                  // Decryption is succeeded.
                }
                else
                {
                  // Token is not match ( Password is not correct )
                  e.Result = new FileDecryptReturnVal(PASSWORD_TOKEN_NOT_FOUND, FilePath);
                  return (false);
                }

                ms.Position = 0;

                var sr = new StreamReader(ms, Encoding.UTF8);
                string line;

                while ((line = sr.ReadLine()) != null)
                {
                  if (Regex.IsMatch(line, @"^[0-9]+:"))
                  {
                    FileList.Add(line);
                  }
                }

              }//end using (MemoryStream ms = new MemoryStream())

            }//end using (CryptoStream cse = new CryptoStream(fs, decryptor, CryptoStreamMode.Read));

              }//end using (Rijndael aes = new RijndaelManaged());

            }
            catch
            {
              e.Result = new FileDecryptReturnVal(ERROR_UNEXPECTED, "");
              return (false);
            }

              }//end using (FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read));

              //----------------------------------------------------------------------
              // Make a list array of the information for each file
              //----------------------------------------------------------------------
              _TotalFileSize = 0;
              string ParentFolder = "";
              bool fDirectoryTraversal = false;
              string InvalidFilePath = "";
              FileList.ForEach(delegate (string OutputLine)
              {
            int LastWriteDate, CreateDate;
            double LastWriteTime, CreateTime;
            DateTime LastWriteDateTime = DateTime.Parse("0001/01/01");
            DateTime CreationDateTime = DateTime.Parse("0001/01/01");

            FileListData fd = new FileListData();
            string[] OutputFileData = OutputLine.Split('\t');

            //-----------------------------------
            // File number
            //
            int FileNum;
            // e.g.)
            // 0:sample.txt[\t]49657[\t]32[\t]736194[\t]39585.875[\t]736194[\t]30186.782[\t]5f43aa1fed05350f34c2fabb7ed938457b2497f2b54a50415b51882f333b8ae1
            string[] FilePathSplits = OutputFileData[0].Split(':');
            if (Int32.TryParse(FilePathSplits[0], out FileNum) == false)
            {
              FileNum = -1;
            }
            //-----------------------------------
            // ディレクトリ・トラバーサル対策
            // Directory traversal countermeasures
            if (OutputFileData[0].IndexOf(@"..\") >= 0)
            {
              fDirectoryTraversal = true;
              InvalidFilePath = OutputFileData[0];
            }

            //-----------------------------------
            // Parent folder is not created.
            //
            if (_fNoParentFolder == true)
            {
              if (FileNum == 0)
              {
            if(FilePathSplits.Length > 2)  // ルートディレクトリ(ex. 0:G:\Test.txt)
            {
              ParentFolder = FilePathSplits[2];
            }
            else
            {
              ParentFolder = FilePathSplits[1];
            }
              }
              else
              {
            if (FilePathSplits.Length > 2)  // ルートディレクトリ
            {
              StringBuilder sb = new StringBuilder(FilePathSplits[2]);
              len = ParentFolder.Length;
              FilePathSplits[2] = sb.Replace(ParentFolder, "", 0, len).ToString();
            }
            else
            {
              StringBuilder sb = new StringBuilder(FilePathSplits[1]);
              len = ParentFolder.Length;
              FilePathSplits[1] = sb.Replace(ParentFolder, "", 0, len).ToString();
            }
              }
            }

            //-----------------------------------
            // File path
            //
            string OutFilePath = "";
            if (_fSalvageIntoSameDirectory == true) // Salvage mode?
            {
              OutFilePath = Path.Combine(OutDirPath, Path.GetFileName(FilePathSplits[1]));
            }
            else
            {
              if(FilePathSplits.Length > 2)
              {
            OutFilePath = Path.Combine(OutDirPath, FilePathSplits[2]);
              }
              else
              {
            OutFilePath = Path.Combine(OutDirPath, FilePathSplits[1]);
              }
            }
            fd.FilePath = OutFilePath;

            //-----------------------------------
            // File size
            if (Int64.TryParse(OutputFileData[1], out fd.FileSize) == false)
            {
              fd.FileSize = -1;
            }
            else
            {
              _TotalFileSize += fd.FileSize;
            }
            //-----------------------------------
            // File attribute
            if (Int32.TryParse(OutputFileData[2], out fd.FileAttribute) == false)
            {
              fd.FileAttribute = -1;
            }

            /*
                    * TTimeStamp = record
                    *  Time: Integer;      { Number of milliseconds since midnight }
                    *  Date: Integer;      { One plus number of days since 1/1/0001 }
                    * end;
                */
            //-----------------------------------
            // Last update timestamp
            if (_fSameTimeStamp == false && Int32.TryParse(OutputFileData[3], out LastWriteDate) == true)
            {
              LastWriteDateTime = LastWriteDateTime.AddDays(LastWriteDate); // Add days
            }
            else
            {
              LastWriteDateTime = DateTime.Now;
            }

            if (_fSameTimeStamp == false && Double.TryParse(OutputFileData[4], out LastWriteTime) == true)
            {
              LastWriteDateTime = LastWriteDateTime.AddSeconds(LastWriteTime);  // Add seconds
            }
            else
            {
              LastWriteDateTime = DateTime.Now;
            }

            fd.LastWriteDateTime = LastWriteDateTime;

            //-----------------------------------
            // Create datetime
            if (_fSameTimeStamp == false && Int32.TryParse(OutputFileData[5], out CreateDate) == true)
            {
              CreationDateTime = CreationDateTime.AddDays(CreateDate);
            }
            else
            {
              CreationDateTime = DateTime.Now;
            }

            if (_fSameTimeStamp == false && Double.TryParse(OutputFileData[6], out CreateTime) == true)
            {
              CreationDateTime = CreationDateTime.AddSeconds(CreateTime);
            }
            else
            {
              CreationDateTime = DateTime.Now;
            }

            fd.CreationDateTime = CreationDateTime;

            //-----------------------------------
            // SHA-256 hash
            if (OutputFileData.Length > 7)
            {
              fd.Hash = OutputFileData[7];
            }

            //-----------------------------------
            // Insert to 'Key-Value' type array data.
            dic.Add(FileNum, fd);

              });

              // Directory traversal countermeasures
              if (fDirectoryTraversal == true)
              {
            e.Result = new FileDecryptReturnVal(INVALID_FILE_PATH, InvalidFilePath);
            return(false);
              }

              //----------------------------------------------------------------------
              // Check the disk space
              //----------------------------------------------------------------------
              string RootDriveLetter = Path.GetPathRoot(OutDirPath).Substring(0, 1);

              if (RootDriveLetter == "\\")
              {
            // Network
              }
              else
              {
            DriveInfo drive = new DriveInfo(RootDriveLetter);

            DriveType driveType = drive.DriveType;
            switch (driveType)
            {
              case DriveType.CDRom:
              case DriveType.NoRootDirectory:
              case DriveType.Unknown:
            break;
              case DriveType.Fixed:     // Local Drive
              case DriveType.Network:   // Mapped Drive
              case DriveType.Ram:       // Ram Drive
              case DriveType.Removable: // Usually a USB Drive

            // The drive is not available, or not enough free space.
            if (drive.IsReady == false || drive.AvailableFreeSpace < _TotalFileSize)
            {
              e.Result = new FileDecryptReturnVal(NO_DISK_SPACE, drive.ToString(), _TotalFileSize, drive.AvailableFreeSpace);
              return (false);
            }
            break;
            }
              }

              //-----------------------------------
              // Decrypt file main data.
              //-----------------------------------
              try
              {
            using (FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
              //-----------------------------------
              // Adjust the header data in 32 bytes
              int mod = _AtcHeaderSize % 32;
              if (_fExecutableType == true)
              {
            fs.Seek(_ExeOutSize + 36 + _AtcHeaderSize + 32 - mod, SeekOrigin.Begin);
              }
              else
              {
            fs.Seek(36 + _AtcHeaderSize + 32 - mod, SeekOrigin.Begin);
              }

              //-----------------------------------
              // Decyption
              using (Rijndael aes = new RijndaelManaged())
              {
            aes.BlockSize = 256;             // BlockSize = 32bytes
            aes.KeySize = 256;               // KeySize = 32bytes
            aes.Mode = CipherMode.CBC;       // CBC mode
            aes.Padding = PaddingMode.Zeros; // Padding mode
            aes.Key = key;
            aes.IV = iv;
            #if (DEBUG)
            //System.Windows.Forms.MessageBox.Show("dic.Count: " + dic.Count);
            #endif
            //Decryption interface.
            ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
            using (CryptoStream cse = new CryptoStream(fs, decryptor, CryptoStreamMode.Read))
            {
              using (Ionic.Zlib.DeflateStream ds = new Ionic.Zlib.DeflateStream(cse, Ionic.Zlib.CompressionMode.Decompress))
              {
                /*
                public struct FileListData
                {
                  public string FilePath;
                  public Int64 FileSize;
                  public int FileAttribute;
                  public DateTime LastWriteDateTime;
                  public DateTime CreationDateTime;
                  public string Sha256String;
                }
                */
                FileStream outfs = null;
                Int64 FileSize = 0;
                int FileIndex = 0;

                bool fSkip = false;

                if (_fNoParentFolder == true)
                {
                  if (dic[0].FilePath.EndsWith("\\") == true)
                  {
                    FileIndex = 1;  // Ignore parent folder.
                  }
                }

                //----------------------------------------------------------------------
                byteArray = new byte[BUFFER_SIZE];

                //while ((len = ds.Read(byteArray, 0, BUFFER_SIZE)) > 0)
                while(true)
                {
                  if (_AppVersion < 3013)
                  {
                    len = cse.Read(byteArray, 0, BUFFER_SIZE);
                  }
                  else
                  {
                    len = ds.Read(byteArray, 0, BUFFER_SIZE);
                  }

                  // 末尾の0バイトファイル、またはフォルダ生成対策
                  if (len == 0) len = 1;

                  int buffer_size = len;

                  while (len > 0)
                  {
                    //----------------------------------------------------------------------
                    // 書き込み中のファイルまたはフォルダが無い場合は作る
                    // Create them if there is no writing file or folder.
                    //----------------------------------------------------------------------
                    if (outfs == null)
                    {
                      //-----------------------------------
                      // Create file or dirctories.
                      if (dic.ContainsKey(FileIndex) == false)
                      {
                        if (FileIndex > dic.Count - 1)
                        {
                          e.Result = new FileDecryptReturnVal(DECRYPT_SUCCEEDED);
                          return (true);
                        }
                        else
                        {
                          e.Result = new FileDecryptReturnVal(FILE_INDEX_NOT_FOUND, FileIndex);
                          return (false);
                        }
                      }
                      else
                      {
                        //-----------------------------------
                        // Create directory
                        //-----------------------------------
                        if (dic[FileIndex].FilePath.EndsWith("\\") == true)
                        {
                          string path = Path.Combine(OutDirPath, dic[FileIndex].FilePath);
                          DirectoryInfo di = new DirectoryInfo(path);

                          // File already exists.
                          if (Directory.Exists(path) == true)
                          {
                            // Temporary option for overwriting
                            // private const int USER_CANCELED  = -1;
                            // private const int OVERWRITE      = 1;
                            // private const int OVERWRITE_ALL  = 2;
                            // private const int KEEP_NEWER     = 3;
                            // private const int KEEP_NEWER_ALL = 4;
                            // private const int SKIP           = 5;
                            // private const int SKIP_ALL       = 6;
                            if (_TempOverWriteOption == OVERWRITE_ALL)
                            {
                              // Overwrite ( New create )
                            }
                            else if (_TempOverWriteOption == SKIP_ALL)
                            {
                              fSkip = true;
                            }
                            else if (_TempOverWriteOption == KEEP_NEWER_ALL)
                            {
                              if (di.LastWriteTime > dic[FileIndex].LastWriteDateTime)
                              {
                                fSkip = true; // old directory
                              }
                            }
                            else
                            {
                              // Show dialog of comfirming to overwrite.
                              dialog(0, path);

                              // Cancel
                              if (_TempOverWriteOption == USER_CANCELED)
                              {
                                e.Result = new FileDecryptReturnVal(USER_CANCELED);
                                return (false);
                              }
                              else if (_TempOverWriteOption == OVERWRITE || _TempOverWriteOption == OVERWRITE_ALL)
                              {
                                // Overwrite ( New create )
                              }
                              // Skip, or Skip All
                              else if (_TempOverWriteOption == SKIP_ALL)
                              {
                                fSkip = true;
                                e.Result = new FileDecryptReturnVal(DECRYPT_SUCCEEDED);
                                return (true);
                              }
                              else if (_TempOverWriteOption == SKIP)
                              {
                                fSkip = true;
                              }
                              else if (_TempOverWriteOption == KEEP_NEWER || _TempOverWriteOption == KEEP_NEWER_ALL)
                              { // New file?
                                if (di.LastWriteTime > dic[FileIndex].LastWriteDateTime)
                                {
                                  fSkip = true;
                                }
                              }
                            }

                            if ( fSkip == false)
                            {
                              //隠し属性を削除する
                              di.Attributes &= ~FileAttributes.Hidden;
                              //読み取り専用を削除
                              di.Attributes &= ~FileAttributes.ReadOnly;
                            }

                            //すべての属性を解除
                            //File.SetAttributes(path, FileAttributes.Normal);

                          } // end if ( Directory.Exists )

                          Directory.CreateDirectory(dic[FileIndex].FilePath);
                          _OutputFileList.Add(dic[FileIndex].FilePath);
                          FileSize = 0;
                          FileIndex++;

                          if (FileIndex > dic.Count - 1)
                          {
                            e.Result = new FileDecryptReturnVal(DECRYPT_SUCCEEDED);
                            return (true);
                          }

                          continue;

                        }
                        //-----------------------------------
                        // Create file
                        //-----------------------------------
                        else
                        {
                          string path = Path.Combine(OutDirPath, dic[FileIndex].FilePath);
                          FileInfo fi = new FileInfo(path);

                          // File already exists.
                          if (File.Exists(path) == true)
                          {
                            // Salvage Data Mode
                            if (_fSalvageIntoSameDirectory == true)
                            {
                              int SerialNum = 0;
                              while (File.Exists(path) == true)
                              {
                                path = getFileNameWithSerialNumber(path, SerialNum);
                                SerialNum++;
                              }
                            }
                            else
                            {
                              // Temporary option for overwriting
                              // private const int USER_CANCELED  = -1;
                              // private const int OVERWRITE      = 1;
                              // private const int OVERWRITE_ALL  = 2;
                              // private const int KEEP_NEWER     = 3;
                              // private const int KEEP_NEWER_ALL = 4;
                              // private const int SKIP           = 5;
                              // private const int SKIP_ALL       = 6;
                              if (_TempOverWriteOption == OVERWRITE_ALL)
                              {
                                // Overwrite ( New create )
                              }
                              else if (_TempOverWriteOption == SKIP_ALL)
                              {
                                fSkip = true;
                              }
                              else if (_TempOverWriteOption == KEEP_NEWER_ALL)
                              {
                                if (fi.LastWriteTime > dic[FileIndex].LastWriteDateTime)
                                {
                                  fSkip = true;
                                }
                              }
                              else
                              {
                                // Show dialog of comfirming to overwrite.
                                dialog(0, path);

                                // Cancel
                                if (_TempOverWriteOption == USER_CANCELED)
                                {
                                  e.Result = new FileDecryptReturnVal(USER_CANCELED);
                                  return (false);
                                }
                                else if (_TempOverWriteOption == OVERWRITE || _TempOverWriteOption == OVERWRITE_ALL)
                                {
                                  // Overwrite ( New create )
                                }
                                // Skip, or Skip All
                                else if (_TempOverWriteOption == SKIP || _TempOverWriteOption == SKIP_ALL)
                                {
                                  fSkip = true;
                                }
                                else if (_TempOverWriteOption == KEEP_NEWER || _TempOverWriteOption == KEEP_NEWER_ALL)
                                { // New file?
                                  if (fi.LastWriteTime > dic[FileIndex].LastWriteDateTime)
                                  {
                                    fSkip = true; // old directory
                                  }
                                }
                              }

                              if (fSkip == false)
                              {
                                //隠し属性を削除する
                                //fi.Attributes &= ~FileAttributes.Hidden;
                                //読み取り専用を削除
                                //fi.Attributes &= ~FileAttributes.ReadOnly;

                                //すべての属性を解除
                                File.SetAttributes(path, FileAttributes.Normal);

                              }

                            }

                          }// end if ( File.Exists );

                          // Salvage data mode
                          // サルベージ・モード
                          if (_fSalvageToCreateParentFolderOneByOne == true)
                          {
                            // Decrypt one by one while creating the parent folder.
                            Directory.CreateDirectory(Path.GetDirectoryName(path));
                          }

                          if ( fSkip == true)
                          {
                            // Not create file
                          }
                          else
                          {
                            outfs = new FileStream(path, FileMode.Create, FileAccess.Write);
                          }

                          _OutputFileList.Add(path);
                          FileSize = 0;

                        }

                      }

                    }// end if (outfs == null);

                    //----------------------------------------------------------------------
                    // Write data
                    //----------------------------------------------------------------------
                    if (FileSize + len < (Int64)dic[FileIndex].FileSize)
                    {
                      if (outfs != null || fSkip == true)
                      {
                        // まだまだ書き込める
                        // can write more
                        if (fSkip == false)
                        {
                          outfs.Write(byteArray, buffer_size - len, len);
                        }
                        FileSize += len;
                        _TotalSize += len;
                        len = 0;
                      }
                    }
                    else
                    {
                      // ファイルの境界を超えて読み込んでいる
                      // Reading beyond file boundaries
                      int rest = (int)(dic[FileIndex].FileSize - FileSize);

                      if (fSkip == false)
                      {
                        // 書き込み完了
                        // Write completed
                        outfs.Write(byteArray, buffer_size - len, rest);
                      }

                      _TotalSize += rest;

                      len -= rest;

                      if (outfs != null)
                      {
                        // 生成したファイルを閉じる
                        // File close
                        outfs.Close();
                        outfs = null;
                      }

                      //----------------------------------------------------------------------
                      // ファイル属性の復元
                      // Restore file attributes

                      if (fSkip == false)
                      {
                        FileInfo fi = new FileInfo(dic[FileIndex].FilePath);
                        // タイムスタンプの復元
                        // Restore the timestamp of a file
                        fi.CreationTime = (DateTime)dic[FileIndex].CreationDateTime;
                        fi.LastWriteTime = (DateTime)dic[FileIndex].LastWriteDateTime;
                        // ファイル属性の復元
                        // Restore file attribute.
                        fi.Attributes = (FileAttributes)dic[FileIndex].FileAttribute;

                        // ハッシュ値のチェック
                        // Check the hash of a file
                        string hash = GetSha256HashFromFile(dic[FileIndex].FilePath);
                        if (hash != dic[FileIndex].Hash.ToString())
                        {
                          e.Result = new FileDecryptReturnVal(NOT_CORRECT_HASH_VALUE, dic[FileIndex].FilePath);
                          return (false);
                        }
                      }

                      FileSize = 0;
                      FileIndex++;

                      fSkip = false;

                      if (FileIndex > dic.Count - 1)
                      {
                        e.Result = new FileDecryptReturnVal(DECRYPT_SUCCEEDED);
                        return (true);
                      }

                    }
                    //----------------------------------------------------------------------
                    //進捗の表示
                    string MessageText = "";
                    if (_TotalNumberOfFiles > 1)
                    {
                      MessageText = FilePath + " ( " + _NumberOfFiles.ToString() + "/" + _TotalNumberOfFiles.ToString() + " files" + " )";
                    }
                    else
                    {
                      MessageText = FilePath;
                    }

                    MessageList = new ArrayList();
                    MessageList.Add(DECRYPTING);
                    MessageList.Add(MessageText);
                    float percent = ((float)_TotalSize / _TotalFileSize);
                    worker.ReportProgress((int)(percent * 10000), MessageList);

                    // User cancel
                    if (worker.CancellationPending == true)
                    {
                      if (outfs != null)
                      {
                        outfs.Close();
                        outfs = null;
                      }
                      e.Cancel = true;
                      return (false);
                    }

                  }// end while(len > 0);

                }// end while ((len = ds.Read(byteArray, 0, BUFFER_SIZE)) > 0);

              }// end using (DeflateStream ds = new DeflateStream(cse, CompressionMode.Decompress));

            }// end using (CryptoStream cse = new CryptoStream(fs, decryptor, CryptoStreamMode.Read));

              }// end using (Rijndael aes = new RijndaelManaged());

            }// end using (FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read));

              }
              catch (Exception ex)
              {
            #if (DEBUG)
            System.Windows.Forms.MessageBox.Show("Exception!");
            #endif

            System.Windows.Forms.MessageBox.Show(ex.Message);

            e.Result = new FileDecryptReturnVal(ERROR_UNEXPECTED);
            return (false);

              }

              e.Result = new FileDecryptReturnVal(DECRYPT_SUCCEEDED);
              return (true);
        }