// download the catalog entry contents and view in an editor

        override public void ReadEntry(ISASTaskConsumer3 consumer, string serverName, string catEntry)
        {
            Consumer = consumer;

            SAS.FileService fs = null;
            SAS.IFileref    fr = null;
            SAS.Workspace   ws = null;
            SAS.TextStream  ts = null;
            string          fileref;

            try
            {
                // use SAS workspace and fileservice to download the file

                ws = consumer.Workspace(serverName) as SAS.Workspace;
                fs = ws.FileService;

                // using the FILENAME CATALOG access method
                fr           = fs.AssignFileref("", "CATALOG", catEntry, "", out fileref);
                ts           = fr.OpenTextStream(SAS.StreamOpenMode.StreamOpenModeForReading, 16500);
                ts.Separator = Environment.NewLine;

                StringBuilder sb = new StringBuilder();

                // downloading catalog entry contents
                int   lines = 1;
                Array truncLines, readLines;
                // iterate through until all lines are read in
                while (lines > 0)
                {
                    ts.ReadLines(100, out truncLines, out readLines);
                    lines = readLines.GetLength(0);
                    for (int i = 0; i < lines; i++)
                    {
                        sb.AppendLine(readLines.GetValue(i).ToString());
                    }
                }

                txtEntry.Text = sb.ToString();

                // cleanup
                ts.Close();
                fs.DeassignFileref(fr.FilerefName);
            }

            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Cannot open the catalog entry {0}.  Reason: {1}", catEntry, ex.Message));
            }
        }
        // download the catalog entry contents and view in an editor

        override public void ReadEntry(ISASTaskConsumer3 consumer, string serverName, string catEntry)
        {
            SAS.FileService  fs = null;
            SAS.IFileref     fr = null;
            SAS.Workspace    ws = null;
            SAS.BinaryStream bs = null;
            string           fileref;

            try
            {
                // use SAS workspace and fileservice to download the file

                ws = consumer.Workspace(serverName) as SAS.Workspace;
                fs = ws.FileService;

                // using the FILENAME CATALOG access method
                fr = fs.AssignFileref("", "CATALOG", catEntry, "", out fileref);
                bs = fr.OpenBinaryStream(StreamOpenMode.StreamOpenModeForReading);

                using (MemoryStream ms = new MemoryStream())
                {
                    // downloading catalog entry contents
                    int   bytes = 1;
                    Array buffer;
                    // iterate through until all lines are read in
                    while (bytes > 0)
                    {
                        bs.Read(32767, out buffer);
                        bytes = buffer.GetLength(0);
                        for (int i = 0; i < bytes; i++)
                        {
                            ms.WriteByte((byte)buffer.GetValue(0));
                        }
                    }

                    ms.Close();
                    BitmapImage b = new BitmapImage();
                    b.BeginInit();
                    b.StreamSource = ms;
                    b.EndInit();

                    imgContent.Source = b;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Cannot open the catalog entry {0}.  Reason: {1}", catEntry, ex.Message));
            }
        }
        // download the catalog entry contents and view in an editor
        public override void ReadEntry(ISASTaskConsumer3 consumer, string serverName, string catEntry)
        {
            Consumer = consumer;

            SAS.FileService fs = null;
            SAS.IFileref fr = null;
            SAS.Workspace ws = null;
            SAS.TextStream ts = null;
            string fileref;

            try
            {
                // use SAS workspace and fileservice to download the file

                ws = consumer.Workspace(serverName) as SAS.Workspace;
                fs = ws.FileService;

                // using the FILENAME CATALOG access method
                fr = fs.AssignFileref("", "CATALOG", catEntry, "", out fileref);
                ts = fr.OpenTextStream(SAS.StreamOpenMode.StreamOpenModeForReading, 16500);
                ts.Separator = Environment.NewLine;

                StringBuilder sb = new StringBuilder();

                // downloading catalog entry contents
                int lines = 1;
                Array truncLines, readLines;
                // iterate through until all lines are read in
                while (lines > 0)
                {
                    ts.ReadLines(100, out truncLines, out readLines);
                    lines = readLines.GetLength(0);
                    for (int i = 0; i < lines; i++)
                        sb.AppendLine(readLines.GetValue(i).ToString());
                }

                txtEntry.Text = sb.ToString();

                // cleanup
                ts.Close();
                fs.DeassignFileref(fr.FilerefName);
            }

            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Cannot open the catalog entry {0}.  Reason: {1}", catEntry, ex.Message));
            }
        }
        // download the catalog entry contents and view in an editor
        public override void ReadEntry(ISASTaskConsumer3 consumer, string serverName, string catEntry)
        {
            SAS.FileService fs = null;
            SAS.IFileref fr = null;
            SAS.Workspace ws = null;
            SAS.BinaryStream bs = null;
            string fileref;

            try
            {
                // use SAS workspace and fileservice to download the file

                ws = consumer.Workspace(serverName) as SAS.Workspace;
                fs = ws.FileService;

                // using the FILENAME CATALOG access method
                fr = fs.AssignFileref("", "CATALOG", catEntry, "", out fileref);
                bs = fr.OpenBinaryStream(StreamOpenMode.StreamOpenModeForReading);

                using (MemoryStream ms = new MemoryStream())
                {
                    // downloading catalog entry contents
                    int bytes = 1;
                    Array buffer;
                    // iterate through until all lines are read in
                    while (bytes > 0)
                    {
                        bs.Read(32767, out buffer);
                        bytes = buffer.GetLength(0);
                        for (int i = 0; i < bytes; i++)
                            ms.WriteByte((byte)buffer.GetValue(0));
                    }

                    ms.Close();
                    BitmapImage b = new BitmapImage();
                    b.BeginInit();
                    b.StreamSource = ms;
                    b.EndInit();

                    imgContent.Source = b;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Cannot open the catalog entry {0}.  Reason: {1}", catEntry, ex.Message));
            }
        }