System.IO.FileAttributes

有MM问木马通过网页把空间文件设为只读属性后,是否可以用网页设回去(文件只读用FTP操作不了文件)。我试验是可以的。

< %@ Import  Namespace = " Microsoft.VisualBasic "  % >
< %@ Import  Namespace = " System.IO "  % >
< !DOCTYPE html  PUBLIC   " -//W3C//DTD XHTML 1.0 Transitional//EN "   " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >

< html xmlns = " http://www.w3.org/1999/xhtml "   >
< head runat = " server " >
    
< title > 无标题页 </ title >
</ head >
< body >
    
< form id = " form1 "  runat = " server " >
    
< div >
    
        
< asp:Button ID = " Button1 "  runat = " server "  onclick = " Button1_Click "  Text = " 设置只读 "   />
& nbsp;
        
< asp:Button ID = " Button2 "  runat = " server "  Text = " 去掉只读 "  onclick = " Button2_Click "   />
    
    
</ div >
    
</ form >
</ body >

< script language = " VB "  runat = server >


    
Public   Sub  FindFile( ByVal   dir   As   String ByVal  boIsReadOnly  As   Boolean ' 参数为指定的目录   
         Dim  Dirpath  As   New  DirectoryInfo( dir )
        
Try
            
Dim  d  As  DirectoryInfo
            
For   Each  d  In  Dirpath.GetDirectories()  ' 查找子目录     
                FindFile(( dir   &  d.ToString()  &   " \ " ), boIsReadOnly)
            
Next  d
            
Dim  f  As  FileInfo
            
Dim  temp  As   String   =   ""
            
For   Each  f  In  Dirpath.GetFiles( " *.* " ' 查找文件   
                temp  =   dir   &  f.ToString()
                
Dim  file1  As   New  System.IO.FileInfo(temp)

                
If  boIsReadOnly  =   True   Then
                    file1.Attributes 
=  System.IO.FileAttributes.ReadOnly
                
Else
                    file1.Attributes 
=  System.IO.FileAttributes.Normal
                
End   If

                
If  file1.Attributes  =  System.IO.FileAttributes.ReadOnly  Then
                    Context.Response.Write(temp 
&   " ---只读<br /> " )
                
ElseIf  file1.Attributes  =  System.IO.FileAttributes.Normal  Then
                    Context.Response.Write(temp 
&   " ---非只读<br /> " )
                
Else
                    Context.Response.Write(temp 
&   " ---未知<br /> " )
                
End   If

            
Next  f
        
Catch  e  As  Exception
            Context.Response.Write(e.Message)
        
End   Try
    
End Sub

    
Protected   Sub  Button1_Click( ByVal  sender  As   Object ByVal  e  As  System.EventArgs)
        FindFile(Server.MapPath(
" ~ " ),  True )
    
End Sub

    
Protected   Sub  Button2_Click( ByVal  sender  As   Object ByVal  e  As  System.EventArgs)
        FindFile(Server.MapPath(
" ~ " ),  False )
    
End Sub
</ script >

</ html >

转载于:https://www.cnblogs.com/LCX/archive/2008/12/12/1353879.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值