对路径 "什么什么" 访问被拒绝
网上查是NTFS的权限没设置好.
检了下 Users 的权限是有的, ASP.NET用户是隶属于它的.
于是在目录上加个 ASPNET 用户的"完全控制"权限, 不行;
再加个 Everyone 用户的"完全控制"权限, 通过.
DATA.DAT
- satan
- satan@263.net
- 2001-6-25 14:03:45
- 1.Asp.net<BR>2.Ado.net<BR>3.Ms.net<BR>...
- lutos
- lutos@163.net
- 2001-6-25 14:04:28
- 呵呵,这是我留言!
- chaos
- chaos@hotmail.com
- 2001-6-25 14:04:57
- 嘿嘿,大家好!ssdfs
- s@ddd.bb
- 2008-12-23 15:55:00
- sdfsdf
- asdf
- sdfsdf@4345.345
- 2008-12-23 15:55:10
- sdfgasfd
textin.aspx
- <% @ import namespace="System.IO"%>
- <Script language="VB" Runat="server">
- sub submit_click(sender as object,e as eventargs)
- Dim stream as FileStream
- Dim StreamWj as StreamWriter
- Dim posttime as string=now
- Dim name,e_mail,text as string
- Dim path as string
- path=Server.MapPath("data.dat")
- Stream = New FileStream(path, FileMode.Append, FileAccess.Write)
- streamWj = New StreamWriter(Stream)
- name=username.value
- e_mail=Email.value
- text=content.value
- text=replace(text,chr(13)+chr(10),"<BR>")
- StreamWj.WriteLine(name)
- StreamWj.WriteLine(e_mail)
- StreamWj.WriteLine(Posttime)
- StreamWj.WriteLine(text)
- StreamWj.Close()
- username.value=""
- email.value=""
- content.value=""
- response.write("谢谢留言!")
- End Sub
- </Script>
- <Html>
- <Head>
- <Title>欢迎留言</Title>
- </Head>
- <Body>
- <form runat="server">
- 姓名:<input type="text" id=username runat="server"></p>
- E_mail:<input type="text" id=email runat="server"></p>
- 留言内容:</p>
- <textarea id="content" cols=40 Rows=4 runat="server" ></TextArea></p>
- <input type=Button value="提交"
- OnServerClick="submit_click" runat="server">
- </form>
- </Body>
- </Html>
textout.aspx
- <% @ import namespace="System.IO"%>
- <Script language="VB" Runat="server">
- Dim pagecount as integer=0 '当前页面
- Dim pagesize as integer=10
- Sub page_load(sender as object,e as eventargs)
- Dim stream as FileStream
- Dim StreamRd as StreamReader
- Dim posttime as string=now
- Dim str as string
- Dim path as string
- Dim i as integer
- Dim j as integer=0
- path=Server.MapPath("data.dat")
- Stream = New FileStream(path,FileMode.OpenOrCreate, FileAccess.Read)
- streamRd = New StreamReader(Stream)
- str=streamRd.ReadLine()
- while (not(str is nothing )) and (j<=pagesize)
- response.Write("<HR>")
- for i=1 to 3
- response.Write(str & "</p>")
- str=streamRd.ReadLine()
- next
- parse(str,70)
- str=streamRd.ReadLine()
- j+=1
- end while
- StreamRd.Close()
- End Sub
- sub parse(str as string,width as integer)
- dim old_pos,tmp_len,i,tot_len as integer
- old_pos=0 '上一次位置
- tmp_len=0 '记录逻辑长度
- tot_len=len(Trim(str))
- for i=1 to tot_len
- '若为中文
- if len(Hex(Asc(Mid(str,i,1))))>2 then
- tmp_len+=2
- else
- tmp_len+=1
- end if
- '如果大于等于(width+2)个字符,输出
- if tmp_len>=(width+2) then
- Response.Write(Mid(str,old_pos+1,i-old_pos))
- Response.write(chr(13)+chr(10))
- '还原计数器
- old_pos=i
- tmp_len=0
- elseif Mid(str,i,4)="<BR>" then
- response.write(Mid(str,old_pos+1,i-old_pos+3))
- i+=3
- old_pos=i
- tmp_len=0
- end if
- next
- '输出其他字符
- if tmp_len>0 then
- response.write(Mid(str,old_pos+1,tot_len-old_pos))
- end if
- End sub
- Sub up_click(sender as object,e as eventargs)
- Dim stream as FileStream
- Dim StreamRd as StreamReader
- Dim posttime as string=now
- Dim str as string
- Dim path as string
- Dim i as integer
- Dim j as integer=1
- path=Server.MapPath("data.dat")
- Stream = New FileStream(path,FileMode.OpenOrCreate, FileAccess.Read)
- streamRd = New StreamReader(Stream)
- count.value+=1
- pagecount=count.value
- for i=1 to pagecount*pagesize*4
- streamRd.ReadLine()
- next
- str=streamRd.ReadLine()
- while (not(str is nothing)) and (j<=pagesize)
- response.Write("<HR>")
- for i=1 to 3
- response.Write(str & "</p>")
- str=streamRd.ReadLine()
- next
- parse(str,70)
- str=streamRd.ReadLine()
- j+=1
- end while
- StreamRd.Close()
- End sub
- Sub down_click(sender as object,e as eventargs)
- Dim stream as FileStream
- Dim StreamRd as StreamReader
- Dim posttime as string=now
- Dim str as string
- Dim path as string
- Dim i as integer
- Dim j as integer=1
- path=Server.MapPath("data.dat")
- Stream = New FileStream(path,FileMode.OpenOrCreate, FileAccess.Read)
- streamRd = New StreamReader(Stream)
- count.value-=1
- pagecount=count.value
- if pagecount>=0 then
- for i=1 to pagecount*pagesize*4
- streamRd.ReadLine()
- next
- str=streamRd.ReadLine()
- while (not(str is nothing)) and (j<=pagesize)
- response.Write("<HR>")
- for i=1 to 3
- response.Write(str & "</p>")
- str=streamRd.ReadLine()
- next
- parse(str,70)
- str=streamRd.ReadLine()
- j+=1
- end while
- StreamRd.Close()
- end if
- End sub
- </Script>
- <Html>
- <Head>
- <Title>查看留言</Title>
- </Head>
- <Body>
- <form runat="server">
- <input type="Button" id="up" value="上一页" OnServerClick="up_click" runat="server"/>
- <input type="Button" id="down" value="下一页" OnServerClick="Down_click" runat="server"/>
- <input type="hidden" id=count value=1 runat="server"/>
- </form>
- </Body>
- </Html>