예제 #1
0
        /// <summary>
        /// 書き込みファイルを読み込む。
        /// </summary>
        /// <param name="photoName">写真名</param>
        private void ReadNotesFile(string photoName)
        {
            try
            {
                string filePath = PhotoChatNote.GetNotesFilePath(photoName);
                using (StreamReader sr = new StreamReader(filePath))
                {
                    // プロパティの読み込み
                    string line = sr.ReadLine();
                    if (line == null || line != Properties)
                    {
                        throw new UnsupportedDataException("不正な書き込みファイル");
                    }
                    if ((line = sr.ReadLine()) != null)
                    {
                        InterpretDataString(line);
                    }

                    // 書き込みデータの読み込み
                    ReadNotes(sr);
                }
            }
            catch (Exception e)
            {
                PhotoChat.WriteErrorLog(e.ToString());
                throw new UnsupportedDataException(e.Message);
            }
        }
예제 #2
0
        /// <summary>
        /// 写真より先に受信した書き込みデータがあれば読み込む。
        /// </summary>
        private void ReadEarlyNotes()
        {
            try
            {
                // 書き込みファイルが作成されていなければ何もしない
                string filePath = PhotoChatNote.GetNotesFilePath(photoName);
                if (!File.Exists(filePath))
                {
                    return;
                }

                // 先行した書き込みデータを読み込む
                using (StreamReader sr = new StreamReader(filePath))
                {
                    ReadNotes(sr);
                }
            }
            catch (Exception e)
            {
                PhotoChat.WriteErrorLog(e.ToString());
            }
        }
예제 #3
0
        /// <summary>
        /// 書き込みファイルを作成する。
        /// </summary>
        private void CreateNotesFile()
        {
            try
            {
                string filePath = PhotoChatNote.GetNotesFilePath(photoName);
                using (StreamWriter sw = new StreamWriter(filePath))
                {
                    // プロパティの保存
                    sw.WriteLine(Properties);
                    sw.WriteLine(GetDataString());

                    // 書き込みデータの保存
                    foreach (PhotoChatNote note in noteList)
                    {
                        sw.WriteLine(note.GetSaveString());
                    }
                    sw.Flush();
                }
            }
            catch (Exception e)
            {
                PhotoChat.WriteErrorLog(e.ToString());
            }
        }