Esempio n. 1
0
        public bool CreateNewFile(SettingsContent.FileType fileType, string fileName)
        {
            bool retValue = false;

            try
            {
                string fileExtName  = fileType == SettingsContent.FileType.PROJECT ? SettingsContent.projectFileExtName : SettingsContent.universalFileExtName;
                string fileFullPath = Path.GetFullPath(fileName + fileExtName);
                string tempFilePath = Path.GetFullPath(SettingsContent.tempFilePath + "\\" + FileEncryption.GUIDGenerate() + ".tmp");
                if (File.Exists(fileFullPath))
                {
                    File.Delete(fileFullPath);
                }

                File.AppendAllText(tempFilePath, string.Empty);
                if (File.Exists(tempFilePath) && !File.Exists(fileFullPath))
                {
                    SetSettingsFilePath(tempFilePath);
                    WriteValue("file_summary", "encrypt", "1");
                    WriteValue("file_summary", "filetype", ((int)fileType).ToString());
                    Dispose();
                    FileEncryption.DesEncryptFile(tempFilePath, fileFullPath, SettingsContent.encryptKey);
                    retValue = true;
                }
            }
            catch (Exception) { };
            return(retValue);
        }
Esempio n. 2
0
 public void SetSettingsFilePath(string path)
 {
     this.sPath = path;
     CheckFileEncrypt();
     if (fileEncrypt)
     {
         originalPath = path;
         tempFileGUID = FileEncryption.GUIDGenerate() + ".tmp";
         FileEncryption.DesDecryptFile(originalPath, SettingsContent.tempFilePath + "\\" + tempFileGUID, SettingsContent.encryptKey);
         this.sPath = SettingsContent.tempFilePath + "\\" + tempFileGUID;
     }
 }
Esempio n. 3
0
 public void Dispose()
 {
     if (fileEncrypt)
     {
         try
         {
             File.Delete(originalPath);
         }
         catch (Exception) { };
         try
         {
             FileEncryption.DesEncryptFile(SettingsContent.tempFilePath + "\\" + tempFileGUID, originalPath, SettingsContent.encryptKey);
         }
         catch (Exception) { };
         try
         {
             File.Delete(SettingsContent.tempFilePath + "\\" + tempFileGUID);
         }
         catch (Exception) { };
     }
     fileEncrypt = false;
     this.sPath  = null;
 }