开发者

I must be missing something - semicolon error that makes no sense

This is the source of my page. I'm getting a mysterious CS1002 error. Been looking at this for awhile now and can't figure it out.

<%@ Page language="C#" validateRequest=false %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Threading" %>
<script language="C#" runat="server">

private void Page_Load (object sender, System.EventArgs e)
{
System.IO.Stream str; String strmContents;
Int32 counter, strLen, strRead;
// Create a Stream object.
str = Request.InputStream;
// Find number of bytes in stream.
strLen = Convert.ToInt32(str.Length);
// Create a byte array.
byte[] strArr = new byte[strLen];
// Read stream into byte array.
strRead = str.Read(strArr, 0, strLen);
writeFile(strArr, "images/test.png");
}

 public void writeFile (byte[] data, String fileName)
{
FileStream out = new FileStream(fileName, FileMode.Open);
out.write(data);
out.close();
}

</script>

It's complaining about a semicolon being expected

Compiler Error Message: CS1002: ; expected

Line 24:    FileStream开发者_JAVA百科 out = new FileStream(fileName, FileMode.Open);


out is a keyword, I don't think you can use it as a variable name. Instead try:

public void writeFile (byte[] data, String fileName)
{
    FileStream fs = new FileStream(fileName, FileMode.Open);
    fs.write(data);
    fs.close();
}


You cant use out, since it's reserved keyword.

http://msdn.microsoft.com/en-us/library/t3c3bfhx%28v=vs.71%29.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜