Link to home
Start Free TrialLog in
Avatar of GoldenJag
GoldenJag

asked on

Filestream Reference

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);
com.solutions.webservices.Crypt ws = new com.solutions.webservices.Crypt();

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);
try
{
      FileWriter.BaseStream.Seek(0, SeekOrigin.End);
      FileWriter.WriteLine(test);
}
catch(Exception e)
{
      Response.Write(e.Message.ToString());
}
finally
{
      FileWriter.Close();
}
Avatar of GoldenJag
GoldenJag

ASKER

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.
Avatar of 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)
     {
         Response.Write(ex.Message.ToString());
     }
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks carl tawn!! that got rid of errors 1 and 2.  Any clue on what to do for error number 3?
See previous post :o)
Thanks!