コード例 #1
0
 public override void RemoveDocument(Document document)
 {
     if (!File.Exists(document.GetPath()))
     {
         throw new ArgumentException("File does not exist (" + document.GetPath() + ")");
     }
     File.Delete(document.GetPath());
     document.Parent.Documents.Remove(document);
 }
コード例 #2
0
        /// <summary>
        /// Save document to file. Take CurrentRevision from Document and overwrite existing file.
        /// </summary>
        /// <param name="document"></param>
        public override void SaveDocument(Document document)
        {
            if (!File.Exists(document.GetPath()))
            {
                throw new ArgumentException("File does not exist (" + document.GetPath() + ")");
            }
            FileStream   fileStream   = new FileStream(document.GetPath(), FileMode.Create, FileAccess.Write);
            StreamWriter streamWriter = new StreamWriter(fileStream);

            string[] lines = document.CurrentRevision.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
            streamWriter.WriteLine(document.CurrentHash);
            foreach (string line in lines)
            {
                streamWriter.WriteLine(line);
            }
            streamWriter.Flush();
            streamWriter.Close();
        }
コード例 #3
0
        /// <summary>
        /// Rename file both in file system and internal system.
        /// </summary>
        /// <param name="document"></param>
        /// <param name="title"></param>
        public void RenameDocument(Document document, string title)
        {
            string documentPath = Path.Combine(document.Parent.GetPath(), Helper.GenerateName(document.Id, GetAvailableName(title, document.Id, document.Parent.GetPath(), ".txt"))) + ".txt";

            try {
                File.Move(document.GetPath(), documentPath);
            } catch (IOException e) {
                // Should not be accesible
                Console.WriteLine(e.Message);
            }
            document.Title = title;
        }
コード例 #4
0
 /// <summary>
 /// Save document to file. Take CurrentRevision from Document and overwrite existing file.
 /// </summary>
 /// <param name="document"></param>
 public override void SaveDocument(Document document)
 {
     if (!File.Exists(document.GetPath())) {
         throw new ArgumentException("File does not exist (" + document.GetPath() + ")");
     }
     FileStream fileStream = new FileStream(document.GetPath(), FileMode.Create, FileAccess.Write);
     StreamWriter streamWriter = new StreamWriter(fileStream);
     string[] lines = document.CurrentRevision.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
     streamWriter.WriteLine(document.CurrentHash);
     foreach (string line in lines) {
         streamWriter.WriteLine(line);
     }
     streamWriter.Flush();
     streamWriter.Close();
 }
コード例 #5
0
 /// <summary>
 /// Rename file both in file system and internal system.
 /// </summary>
 /// <param name="document"></param>
 /// <param name="title"></param>
 public void RenameDocument(Document document, string title)
 {
     string documentPath = Path.Combine(document.Parent.GetPath(), Helper.GenerateName(document.Id, GetAvailableName(title, document.Id, document.Parent.GetPath(), ".txt"))) + ".txt";
     try {
         File.Move(document.GetPath(), documentPath);
     } catch (IOException e) {
         // Should not be accesible
         Console.WriteLine(e.Message);
     }
     document.Title = title;
 }
コード例 #6
0
 public override void RemoveDocument(Document document)
 {
     if (!File.Exists(document.GetPath())) {
         throw new ArgumentException("File does not exist (" + document.GetPath() + ")");
     }
     File.Delete(document.GetPath());
     document.Parent.Documents.Remove(document);
 }