ASP C# String problem

A

Aries

Hi all
I have a program looks like this.

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>

<html>
<script Language="C#" runat="server">
StreamReader din =
File.OpenText("C:\\Inetpub\\wwwroot\\main\\deployment\\test\\version.txt");
String str;
str = din.ReadLine();

</script>

<body>
<h1>testing</h1>
Text in file <asp:label id="str" font-size="24" font-bold="true"
runat=server/>

</body>
</html>


I get an error message:
Compiler Error Message: CS1519: Invalid token '=' in class, struct, or
interface member declaration

But if I do something like this

<script Language="C#" runat="server">

void Page_Load(Object source, EventArgs e) {
StreamReader din =
File.OpenText("C:\\Inetpub\\wwwroot\\main\\Deployment\\test\\version2.txt");
String str;
str = din.ReadLine();
}
</script>

I got no error message but the str doesn't give me anything.


Can some one please help me out on how to fix the problem? There is only 1
line in the version.txt. Version.txt has something like "2.5.1" (there is
quote in it).

thanks.

ÁÙ§Ú¥»¦â
Forever Bad.
 

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

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,267
Latest member
WaylonCogb

Latest Threads

Top