示例#1
0
        /// <summary>
        /// Opens an UCOMIStream and returns the associated file object
        /// </summary>
        /// <param name="parentStorage">storage used to open the stream</param>
        /// <param name="fileName">filename of the stream</param>
        /// <returns>A <see cref="FileObject">FileObject</see> instance if the file was found, otherwise null.</returns>
        public FileObject OpenUCOMStream(Interop.IStorage parentStorage, string fileName)
        {
            if (parentStorage == null)
            {
                parentStorage = storage;
            }

            FileObject retObject = null;

            STATSTG sTATSTG;

            sTATSTG.pwcsName = fileName;
            sTATSTG.type     = 2;

            try
            {
                retObject = new FileObject();

                UCOMIStream uCOMIStream = parentStorage.OpenStream(sTATSTG.pwcsName, IntPtr.Zero, 16, 0);

                if (uCOMIStream != null)
                {
                    retObject.FileType   = sTATSTG.type;
                    retObject.FilePath   = "";
                    retObject.FileName   = sTATSTG.pwcsName.ToString();
                    retObject.FileStream = uCOMIStream;
                }
                else
                {
                    retObject = null;
                }
            }
            catch (Exception ex)
            {
                retObject = null;

                Debug.WriteLine("ITStorageWrapper.OpenUCOMStream() - Failed for file '" + fileName + "'");
                Debug.Indent();
                Debug.WriteLine("Exception: " + ex.Message);
                Debug.Unindent();
            }

            return(retObject);
        }
 /// <summary>
 /// Adds a new file object to the collection
 /// </summary>
 /// <param name="fo">file object instance to add</param>
 public void Add(FileObject fo)
 {
     base.List.Add(fo);
 }