コード例 #1
0
ファイル: ReaderWriter.cs プロジェクト: newlysoft/NStorage
        /* ********** START implementation of POIFSReaderListener ********** */

        /**
         * Process a POIFSReaderEvent that this listener had registered
         * for
         *
         * @param evt the POIFSReaderEvent
         */

        public void ProcessPOIFSReaderEvent(POIFSReaderEvent evt)
        {
            DocumentInputStream istream = evt.Stream;
            POIFSDocumentPath path = evt.Path;
            String name = evt.Name;

            try
            {
                int size = (int)(istream.Length - istream.Position);
                byte[] data = new byte[size];

                istream.Read(data);
                DocumentDescriptor descriptor = new DocumentDescriptor(path,
                                                    name);

                Console.WriteLine("Adding document: " + descriptor + " (" + size
                                   + " bytes)");
                dataMap[descriptor] = data;
                DirectoryEntry entry = root;

                for (int k = 0; k < path.Length; k++)
                {
                    String componentName = path.GetComponent(k);
                    Entry nextEntry = null;

                    try
                    {
                        nextEntry = entry.GetEntry(componentName);
                    }
                    catch (FileNotFoundException)
                    {
                        try
                        {
                            nextEntry = entry.CreateDirectory(componentName);
                        }
                        catch (IOException)
                        {
                            Console.WriteLine("Unable to Create directory");
                            //e.printStackTrace();
                            throw;
                        }
                    }
                    entry = (DirectoryEntry)nextEntry;
                }
                entry.CreateDocument(name, size, this);
            }
            catch (IOException)
            {
            }
        }
コード例 #2
0
ファイル: Listener.cs プロジェクト: newlysoft/NStorage
        /**
         * Process a POIFSReaderEvent that this listener had registered
         * for
         *
         * @param evt the POIFSReaderEvent
         */

        public void ProcessPOIFSReaderEvent(POIFSReaderEvent evt)
        {
        }