Filestream Reference

Posted on 2006-04-13
Last Modified: 2008-01-09
With this snipplet of code.  What do i need to reference in C# to get this to work? Or what am i doing wrong?
i get the following errors:
1.  System.EventArgs' does not contain a definition for 'Message'
2.  A local variable named 'e' cannot be declared in this scope because it would give a different meaning to 'e', which is already used in a 'parent or current' scope to denote something else
3. Cannot create an instance of the abstract class or interface 'System.IO.Stream'

I have the following already referenced:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;

int fileid = Convert.ToInt32(DataGrid1.SelectedItem.Cells[1].Text); ws = new;

byte[] test = ws.DecryptStoredFile(pm.sessionKey,fileid);

string FileName = Path.GetTempFileName();
FileStream File_Stream = new FileStream(FileName, FileMode.Append, FileAccess.Write);
StreamWriter FileWriter = new Stream(File_Stream);
      FileWriter.BaseStream.Seek(0, SeekOrigin.End);
catch(Exception e)
Question by:GoldenJag

    Author Comment

    Sorry, i wasnt very clear.

    error number 1 comes from this snipplet of code:  Response.Write(e.Message.ToString());

    error number 2 comes from this snipplet: catch(Exception e)

    error number 3 comes from this snipplet: StreamWriter FileWriter = new Stream(File_Stream);   // new is underlined  

    Error number 3 is my main concern.
    LVL 52

    Expert Comment

    by:Carl Tawn
    If your code is part of an event handler then e.Message is causing a conflict with "EventArgs e" in the event arguments. Try changing to:

         catch (Exception ex)
    LVL 52

    Accepted Solution

    Error 3 comes from you trying to create a new Stream (which is an abstract class).


        StreamWriter FileWriter = new StreamWriter(File_Stream);

    Author Comment

    Thanks carl tawn!! that got rid of errors 1 and 2.  Any clue on what to do for error number 3?
    LVL 52

    Expert Comment

    by:Carl Tawn
    See previous post :o)

    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now