zoukankan      html  css  js  c++  java
  • 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 StringByVal 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 ObjectByVal e As System.EventArgs)
            FindFile(Server.MapPath(
    "~"), True)
        
    End Sub

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

    </html>
  • 相关阅读:
    JAVA 基础 / 第二十三课: 类和对象 / 什么是JAVA中的方法重载? 构造方法?
    JAVA 基础 / 第二十二课: 类和对象 / 什么是JAVA中的引用? 继承 ?
    【Oracle】ORA-12518, TNS:listener could not hand off client connection
    Oracle 将当前系统时间戳插入timestamp字段 无效的月份
    Git本地有未提交文件,直接拉取远端最新版本
    Windows下分布式环境搭建以及简单测试
    Python——pip快速下载第三方库到指定环境
    Python——Scrapy爬取链家网站所有房源信息
    Python——XPath提取某个标签下所有文本
    Python——全国瓜子二手车数据分析
  • 原文地址:https://www.cnblogs.com/LCX/p/1353879.html
Copyright © 2011-2022 走看看