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); }
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)); } } }
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; }
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); } } }