Esempio n. 1
0
        private SaveResult SaveTempText(String path, SaveEmergencyMode mode)
        {
            String dirPath  = GetTempFolderPath(mode);
            String destPath = dirPath + "\\" + GetTempFileName(path);

            try
            {
                if (!Directory.Exists(dirPath))
                {
                    Directory.CreateDirectory(dirPath);
                }

                StreamWriter stream = new StreamWriter(new FileStream(destPath, FileMode.CreateNew), Encoding.GetEncoding("Shift-jis"));
                stream.Write(ModelsComposite.DocumentModel.Text);
                stream.Close();
            }
            catch (Exception)
            {
                return(SaveResult.CompletelyFailed);
            }

            return(SaveResult.Succeed);
        }
Esempio n. 2
0
        private String GetTempFolderPath(SaveEmergencyMode mode)
        {
            switch (mode)
            {
            case SaveEmergencyMode.AssemblyTemp:
            {
                string assemblyLocation = CommonDirectoryUtil.GetCommonProgramDataAppliPath();

                String dirPath = Path.GetDirectoryName(assemblyLocation);
                return(dirPath + "\\temp");
            }

            case SaveEmergencyMode.DocumentTemp:
            {
                return(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal));
            }

            case SaveEmergencyMode.FinalTemp:
            default:
            {
                return(System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
            }
            }
        }
Esempio n. 3
0
        private SaveResult SaveTempText(String path, SaveEmergencyMode mode)
        {
            String dirPath = GetTempFolderPath(mode);
            String destPath = dirPath + "\\" + GetTempFileName(path);

            try
            {
                if (!Directory.Exists(dirPath))
                {
                    Directory.CreateDirectory(dirPath);
                }

                StreamWriter stream = new StreamWriter(new FileStream(destPath, FileMode.CreateNew), Encoding.GetEncoding("Shift-jis"));
                stream.Write(ModelsComposite.DocumentModel.Text);
                stream.Close();
            }
            catch (Exception)
            {
                return SaveResult.CompletelyFailed;
            }

            return SaveResult.Succeed;
        }
Esempio n. 4
0
        private String GetTempFolderPath(SaveEmergencyMode mode)
        {
            switch (mode)
            {
                case SaveEmergencyMode.AssemblyTemp:
                    {
                        string assemblyLocation = CommonDirectoryUtil.GetCommonProgramDataAppliPath();

                        String dirPath = Path.GetDirectoryName(assemblyLocation);
                        return dirPath + "\\temp";
                    }
                case SaveEmergencyMode.DocumentTemp:
                    {
                        return System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                    }
                case SaveEmergencyMode.FinalTemp:
                default:
                    {
                        return System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                    }

            }
        }