HELP!!!!!!!!!!!!!

E

eric.flores13

this keeps giving me a compilation error for
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name
'FileStream' could not be found (are you missing a using directive or
an assembly reference?)





<%@ Page Language="C#" Debug="true" %>


<script runat="server">

public void SelectedAns(object sender, EventArgs e)
{

litSurvey.Text = "";



litDemo.Text = "Thank you for taking this survey.";

string path = Server.MapPath("../Database/survey.txt");
FileStream fs = new FileStream(path, FileMode.Append,
FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(DateTime.Now);
sw.WriteLine(litSurvey.Text);
sw.Close( );


String gender, race, emplo, age = "";

gender = RadioGender.SelectedValue;
race = RadioRace.SelectedValue;
emplo= ddlEmployStat.SelectedValue;

String depaul, town, sportsTeam, player, band;
depaul = RadioQ1.SelectedValue;
town = RadioQ2.SelectedValue;
sportsTeam = RadioQ3.SelectedValue;
player = RadioQ4.SelectedValue;
band = RadioQ5.SelectedValue;


if (ddlAge.SelectedValue == "ageOne")
{
age = " under the age of 18 ";
}
else if (ddlAge.SelectedValue == "ageTwo")
{
age = " between 18 and 21 ";
}
else if (ddlAge.SelectedValue == "ageThree")
{
age = " between 22 and 25 ";
}
else if (ddlAge.SelectedValue == "ageFour")
{
age = " between 26 and 28 ";
}
else if (ddlAge.SelectedValue == "ageFive")
{
age = " between 29 and 32 ";
}
else if (ddlAge.SelectedValue == "ageSix")
{
age = " over the age of 33 ";
}


litSurvey.Text = "Gender: " + gender + "Age: " + age + "Income: "
+ annualIncome.Text +
"Zip Code: " + zipcode.Text + "Currently " + emplo + " and " + depaul
+ " at Depaul University." + "Originally from " + town +
"Favorite Chicago sports team is the Chicago " + sportsTeam +
"Favorite Chicago sports player is " + player +
"Favorite Chicago local music act is " + band;


}

</script>

<html>
<head>
<title>Depaul Survery</title>

<link rel="stylesheet" href="../styles.css" type="text/css"></link>

</head>
<body>
<h1>Depaul University Survery</h1>

<img src="logo.gif" width="271" height="240" />
<br />

Thank you for visiting the student Depaul University survey website.
The admitions office is trying to gather information of students.
Depaul University, with more than 24,300 students, is the only one of
the nation's largest private universities where the faculty priority
is on teaching. Depaul offers a high caliber, challenging learning
environment that is respected by the community. This survey is trying
to gather the information of the students to offer rewards for
excelling in classes. We are trying to set up discount tickets with
chicago teams and also bring a local artist band to play in our
campus. Please take the time to answer all the questions. Thank you!

<form id="form1" runat="server">

<h3> Demographic Information:</h3>

<asp:Literal ID="gender" runat="server" Text="Gender:"></
asp:Literal>
<asp:RadioButtonList ID="RadioGender" runat="server"
AutoPostBack="false" >
<asp:ListItem Value="female">Female</asp:ListItem>
<asp:ListItem Value="male">Male</asp:ListItem>
</asp:RadioButtonList>

<br />
<asp:Literal ID="age" runat="server" Text="Age:"></
asp:Literal>
<asp:ListItem Value="ageOne">Under 18</asp:ListItem>
<asp:ListItem Value="ageTwo">18-21</asp:ListItem>
<asp:ListItem Value="ageThree">22-25</asp:ListItem>
<asp:ListItem Value="ageFour">26-28</asp:ListItem>
<asp:ListItem Value="ageFive">29-32</asp:ListItem>
<asp:ListItem Value="ageSix">33+</asp:ListItem>
</asp:DropDownList>
<br />

<br />
Annual Income:<br />
<asp:TextBox ID="annualIncome" size = "15" Text = ""
runat="server" ></asp:TextBox>
<br />
<br />
Zip Code:<br />
<asp:TextBox ID="zipcode" size = "6" Text = "" runat="server" ></
asp:TextBox>
<asp:RangeValidator runat="server"
ControlToValidate="zipcode"
MinimumValue="0" MaximumValue="99999"
Type="Integer"
ErrorMessage="Enter a zip code that is equal to five
digits" />
<br />
<br />
<asp:Literal ID="race" runat="server" Text="Race:"></asp:Literal>
<asp:RadioButtonList ID="RadioRace" runat="server"
AutoPostBack="false" >
<asp:ListItem Value="caucasion">Caucasian</asp:ListItem>
<asp:ListItem Value="black">African-American</asp:ListItem>
<asp:ListItem Value="hispanic">Hispanic</asp:ListItem>
<asp:ListItem Value="asian/Pacific Islander">Asian/Pacific
Islander</asp:ListItem>
<asp:ListItem Value="Native American">Native American</
asp:ListItem>
<asp:ListItem Value="nonlatino">Non-Hispanic</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Literal ID="studentSurvey" runat="server" Text="<h3>Student
Survey:</h3>"></asp:Literal>


1. What year are you in Depaul?
<asp:RadioButtonList
ID="RadioQ1" runat="server" AutoPostBack="false" >
<asp:ListItem Value="Freshman">Freshman</asp:ListItem>
<asp:ListItem Value="Sophmore">Sophmore</asp:ListItem>
<asp:ListItem Value="Junior">Junior</asp:ListItem>
<asp:ListItem Value="Senior">Senior</asp:ListItem>
<asp:ListItem Value="Grad Student">Grad Student</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Literal ID="empStatus" runat="server" Text="2. Employment
Status:"></asp:Literal>
<br />
<asp:DropDownList ID="ddlEmployStat" runat="server"
AutoPostBack="false" >
<asp:ListItem Value="a student">I. Student</asp:ListItem>
<asp:ListItem Value="a student with internship">II. Student with
Internship</asp:ListItem>
<asp:ListItem Value="employed">III. Employed</asp:ListItem>
<asp:ListItem Value="unemployed">IV. Unemployed</asp:ListItem>
</asp:DropDownList>
<br />
<br />

3. Are originally from Chicago?<asp:RadioButtonList
ID="RadioQ2" runat="server" AutoPostBack="false" >
<asp:ListItem Value="Chicago">Yes</asp:ListItem>
<asp:ListItem Value="Chicagoland Area">Around the Chicagoland
area.</asp:ListItem>
<asp:ListItem Value="out of state">Out of State</asp:ListItem>
</asp:RadioButtonList>
<br />
4. What is your favorite Chicago sports team?<asp:RadioButtonList
ID="RadioQ3" runat="server" AutoPostBack="false" >
<asp:ListItem Value="Bulls">NBA: Chicago Bulls</asp:ListItem>
<asp:ListItem Value="Blackhawks">NHL: Chicago Blackhawks</
asp:ListItem>
<asp:ListItem Value="White Sox">MLB: Chicago White Sox</
asp:ListItem>
<asp:ListItem Value="Cubs">MLB: Chicago Cubs</asp:ListItem>
<asp:ListItem Value="Bears">NFL: Chicago Bears</asp:ListItem>
<asp:ListItem Value="Fire">MLS: Chicago Fire</asp:ListItem>
</asp:RadioButtonList>
<br />
5. Who is your favorite Chicago sports player of all time?
<asp:RadioButtonList
ID="RadioQ4" runat="server" AutoPostBack="false" >
<asp:ListItem Value="Ernie Banks">Ernie Banks</asp:ListItem>
<asp:ListItem Value="Mike Ditka">Mike Ditka</asp:ListItem>
<asp:ListItem Value="Walter Payton">Walter Payton</
asp:ListItem>
<asp:ListItem Value="Micheal Jordon">Micheal Jordan</
asp:ListItem>
</asp:RadioButtonList>
<br />
6. Who is your favorite Chicago music artist?<asp:RadioButtonList
ID="RadioQ5" runat="server" AutoPostBack="false" >
<asp:ListItem Value="Kanye West">Kanye West</asp:ListItem>
<asp:ListItem Value="Lupe Fiasco">Lupe Fiasco</asp:ListItem>
<asp:ListItem Value="Disturbed">Disturbed</asp:ListItem>
<asp:ListItem Value="Rise Against">Rise Against</asp:ListItem>
<asp:ListItem Value="The Smashing Pumpkins">The Smashing
Pumpkins</asp:ListItem>
<asp:ListItem Value="Frankie Knuckles">Frankie Knuckles</
asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Button ID="Button1" runat="server" Text="Submit Survey"
OnClick="SelectedAns"/>
<p><asp:Literal ID="university" Text="" runat="server" /></p>
<p>Demographin Info:<br /><asp:Literal ID="litDemo" Text=""
runat="server" /></p>
<p>Survey Info: <br /><asp:Literal ID="litSurvey" Text=""
runat="server" /></p>


</form>
</body>
</html>
 
P

Peter

this keeps giving me a compilation error for
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name
'FileStream' could not be found (are you missing a using directive or
an assembly reference?)

<%@ Page Language="C#" Debug="true" %>

<cut>

Maybe you're missing something like
<%@ Import Namespace="System.IO.FileStream" %>
 
A

Alberto Poblacion

Peter said:
Maybe you're missing something like
<%@ Import Namespace="System.IO.FileStream" %>


I believe that the import should contain the namespace only, not the class:
<%@ Import Namespace="System.IO" %>
 
M

Manu Singhal

Make sure you have referenced the correct DLL and are using the using
Directive properly
 
I

Ignacio Machin ( .NET/ C# MVP )

this keeps giving me a compilation error for
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name
'FileStream' could not be found (are you missing a using directive or
an assembly reference?)

<%@ Page Language="C#" Debug="true" %>

<script runat="server">

public void SelectedAns(object sender, EventArgs e)
{

    litSurvey.Text = "";

    litDemo.Text = "Thank you for taking this survey.";

    string path = Server.MapPath("../Database/survey.txt");
    FileStream fs = new FileStream(path, FileMode.Append,
                                         FileAccess.Write);
    StreamWriter sw = new StreamWriter(fs);
    sw.WriteLine(DateTime.Now);
    sw.WriteLine(litSurvey.Text);
    sw.Close( );

    String gender, race, emplo, age = "";

    gender = RadioGender.SelectedValue;
    race = RadioRace.SelectedValue;
    emplo= ddlEmployStat.SelectedValue;

    String depaul, town, sportsTeam, player, band;
    depaul = RadioQ1.SelectedValue;
    town = RadioQ2.SelectedValue;
    sportsTeam = RadioQ3.SelectedValue;
    player = RadioQ4.SelectedValue;
    band = RadioQ5.SelectedValue;

    if (ddlAge.SelectedValue == "ageOne")
    {
        age = " under the age of 18 ";
    }
    else if (ddlAge.SelectedValue == "ageTwo")
    {
        age = " between 18 and 21 ";
    }
    else if (ddlAge.SelectedValue == "ageThree")
    {
        age = " between 22 and 25 ";
    }
    else if (ddlAge.SelectedValue == "ageFour")
    {
        age = " between 26 and 28 ";
    }
    else if (ddlAge.SelectedValue == "ageFive")
    {
        age = " between 29 and 32 ";
    }
    else if (ddlAge.SelectedValue == "ageSix")
    {
        age = " over the age of 33 ";
    }

    litSurvey.Text = "Gender: " + gender + "Age: " + age + "Income:"
+ annualIncome.Text +
        "Zip Code: " + zipcode.Text + "Currently " + emplo + " and " + depaul
+ " at Depaul University." + "Originally from " + town +
                        "Favorite Chicago sports team is the Chicago " + sportsTeam +
                                "FavoriteChicago sports player is " + player +
                                "FavoriteChicago local music act is " + band;

}

</script>

<html>
<head>
    <title>Depaul Survery</title>

<link rel="stylesheet" href="../styles.css" type="text/css"></link>

</head>
<body>
    <h1>Depaul University Survery</h1>

<img src="logo.gif" width="271" height="240" />
<br />

Thank you for visiting the student Depaul University survey website.
The admitions office is trying to gather information of students.
Depaul University, with more than 24,300 students, is the only one of
the nation's largest private universities where the faculty priority
is on teaching. Depaul offers a high caliber, challenging learning
environment that is respected by the community. This survey is trying
to gather the information of the students to offer rewards for
excelling in classes. We are trying to set up discount tickets with
chicago  teams and also bring a local artist band to play in our
campus. Please take the time to answer all the questions. Thank you!

    <form id="form1" runat="server">

    <h3> Demographic Information:</h3>

    <asp:Literal ID="gender" runat="server" Text="Gender:"></
asp:Literal>
    <asp:RadioButtonList ID="RadioGender" runat="server"
AutoPostBack="false"  >
        <asp:ListItem Value="female">Female</asp:ListItem>
        <asp:ListItem Value="male">Male</asp:ListItem>
    </asp:RadioButtonList>

    <br />
        <asp:Literal ID="age" runat="server" Text="Age:"></
asp:Literal>
    <br />
    <asp:DropDownList ID="ddlAge" runat="server" AutoPostBack="false"

        <asp:ListItem Value="ageOne">Under 18</asp:ListItem>
        <asp:ListItem Value="ageTwo">18-21</asp:ListItem>
        <asp:ListItem Value="ageThree">22-25</asp:ListItem>
        <asp:ListItem Value="ageFour">26-28</asp:ListItem>
        <asp:ListItem Value="ageFive">29-32</asp:ListItem>
        <asp:ListItem Value="ageSix">33+</asp:ListItem>
    </asp:DropDownList>
    <br />

    <br />
    Annual Income:<br />
    <asp:TextBox ID="annualIncome" size = "15" Text = ""
runat="server" ></asp:TextBox>
    <br />
<br />
    Zip Code:<br />
    <asp:TextBox ID="zipcode" size = "6" Text = "" runat="server" ></
asp:TextBox>
     <asp:RangeValidator runat="server"
             ControlToValidate="zipcode"
             MinimumValue="0" MaximumValue="99999"
             Type="Integer"
             ErrorMessage="Enter a zip code that is equalto five
digits" />
    <br />
    <br />
    <asp:Literal ID="race" runat="server" Text="Race:"></asp:Literal>
    <asp:RadioButtonList ID="RadioRace" runat="server"
AutoPostBack="false" >
        <asp:ListItem Value="caucasion">Caucasian</asp:ListItem>
        <asp:ListItem Value="black">African-American</asp:ListItem>
        <asp:ListItem Value="hispanic">Hispanic</asp:ListItem>
        <asp:ListItem Value="asian/Pacific Islander">Asian/Pacific
Islander</asp:ListItem>
        <asp:ListItem Value="Native American">Native American</
asp:ListItem>
        <asp:ListItem Value="nonlatino">Non-Hispanic</asp:ListItem>
    </asp:RadioButtonList>
    <br />
<asp:Literal ID="studentSurvey" runat="server" Text="<h3>Student
Survey:</h3>"></asp:Literal>

    1. What year are you in Depaul?
    <asp:RadioButtonList
        ID="RadioQ1" runat="server" AutoPostBack="false" >
        <asp:ListItem Value="Freshman">Freshman</asp:ListItem>
        <asp:ListItem Value="Sophmore">Sophmore</asp:ListItem>
        <asp:ListItem Value="Junior">Junior</asp:ListItem>
        <asp:ListItem Value="Senior">Senior</asp:ListItem>
        <asp:ListItem Value="Grad Student">Grad Student</asp:ListItem>
    </asp:RadioButtonList>
    <br />
    <asp:Literal ID="empStatus" runat="server" Text="2. Employment
Status:"></asp:Literal>
    <br />
    <asp:DropDownList ID="ddlEmployStat" runat="server"
AutoPostBack="false" >
        <asp:ListItem Value="a student">I. Student</asp:ListItem>
        <asp:ListItem Value="a student with internship">II. Student with
Internship</asp:ListItem>
        <asp:ListItem Value="employed">III. Employed</asp:ListItem>
        <asp:ListItem Value="unemployed">IV. Unemployed</asp:ListItem>
    </asp:DropDownList>
    <br />
    <br />

    3. Are originally from Chicago?<asp:RadioButtonList
        ID="RadioQ2" runat="server" AutoPostBack="false" >
        <asp:ListItem Value="Chicago">Yes</asp:ListItem>
        <asp:ListItem Value="Chicagoland Area">Around the Chicagoland
area.</asp:ListItem>
        <asp:ListItem Value="out of state">Out of State</asp:ListItem>
    </asp:RadioButtonList>
    <br />
    4. What is your favorite Chicago sports team?<asp:RadioButtonList
        ID="RadioQ3" runat="server" AutoPostBack="false" >
        <asp:ListItem Value="Bulls">NBA: Chicago Bulls</asp:ListItem>
        <asp:ListItem Value="Blackhawks">NHL: Chicago Blackhawks</
asp:ListItem>
        <asp:ListItem Value="White Sox">MLB: Chicago White Sox</
asp:ListItem>
        <asp:ListItem Value="Cubs">MLB: Chicago Cubs</asp:ListItem>
        <asp:ListItem Value="Bears">NFL: Chicago Bears</asp:ListItem>
        <asp:ListItem Value="Fire">MLS: Chicago Fire</asp:ListItem>
    </asp:RadioButtonList>
    <br />
    5. Who is your favorite Chicago sports player of all time?
<asp:RadioButtonList
        ID="RadioQ4" runat="server" AutoPostBack="false" >
        <asp:ListItem Value="Ernie Banks">Ernie Banks</asp:ListItem>
        <asp:ListItem Value="Mike Ditka">Mike Ditka</asp:ListItem>
        <asp:ListItem Value="Walter Payton">Walter Payton</
asp:ListItem>
        <asp:ListItem Value="Micheal Jordon">Micheal Jordan</
asp:ListItem>
    </asp:RadioButtonList>
    <br />
    6. Who is your favorite Chicago music artist?<asp:RadioButtonList
        ID="RadioQ5" runat="server" AutoPostBack="false" >
        <asp:ListItem Value="Kanye West">Kanye West</asp:ListItem>
        <asp:ListItem Value="Lupe Fiasco">Lupe Fiasco</asp:ListItem>
        <asp:ListItem Value="Disturbed">Disturbed</asp:ListItem>
        <asp:ListItem Value="Rise Against">Rise Against</asp:ListItem>
        <asp:ListItem Value="The Smashing Pumpkins">The Smashing
Pumpkins</asp:ListItem>
        <asp:ListItem Value="Frankie Knuckles">Frankie Knuckles</
asp:ListItem>
    </asp:RadioButtonList>
    <br />
    <asp:Button ID="Button1" runat="server" Text="Submit Survey"
OnClick="SelectedAns"/>
        <p><asp:Literal ID="university" Text="" runat="server" /></p>
        <p>Demographin Info:<br /><asp:Literal ID="litDemo" Text=""
runat="server" /></p>
        <p>Survey Info: <br /><asp:Literal ID="litSurvey" Text=""
runat="server" /></p>

    </form>
</body>
</html>

Hi,

you are missing the using directive for System.IO
otherwise you can change these lines:

FileStream fs = new FileStream(path, FileMode.Append,
StreamWriter sw = new StreamWriter(fs);

to:


System.IO.FileStream fs = new System.IO.FileStream(path,
FileMode.Append,
System.IO.StreamWriter sw = new System.IO.StreamWriter(fs);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top