Example #1
0
        /// <summary>
        /// Creates a document
        /// </summary>
        /// <param name="name">The name of the document to create</param>
        /// <returns>The created document</returns>
        /// <exception cref="UnauthorizedAccessException">The file system is read-only</exception>
        /// <exception cref="IOException">Document or collection with the same name already exists</exception>
        public InMemoryFile CreateDocument(string name)
        {
            if (InMemoryFileSystem.IsReadOnly)
            {
                throw new UnauthorizedAccessException("Failed to modify a read-only file system");
            }
            if (_children.ContainsKey(name))
            {
                throw new IOException("Document or collection with the same name already exists");
            }
            var newItem = new InMemoryFile(InMemoryFileSystem, this, Path.Append(name, false), name);

            _children.Add(newItem.Name, newItem);
            ETag = new EntityTag(false);
            return(newItem);
        }
Example #2
0
 public MyMemoryStream(InMemoryFile file)
 {
     _file = file;
 }