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>
  • 相关阅读:
    [C++ Primer Plus] 第9章、内存模型和名称空间(二)课后习题
    [C++ Primer Plus] 第9章、内存模型和名称空间(一)程序清单
    [c/c++] programming之路(28)、结构体存储和内存对齐+枚举类型+typedef+深拷贝和浅拷贝
    [c/c++] programming之路(27)、union共用体
    [c/c++] programming之路(26)、结构体
    opencv学习之路(37)、运动物体检测(二)
    [Python]基础教程(4)、Python 变量类型
    opencv学习之路(36)、运动物体检测(一)
    opencv学习之路(35)、SURF特征点提取与匹配(三)
    opencv学习之路(34)、SIFT特征匹配(二)
  • 原文地址:https://www.cnblogs.com/LCX/p/1353879.html
Copyright © 2011-2022 走看看