• FreeDiskSpaceViewer


    asp.net在win2003中会以network service身份运行,可能需要为该帐户设置权限
     
    FreeDiskSpaceViewer.aspx
    --Code Begin----------------------------------------------------
    <%@ Page Language="C#" AutoEventWireup="true" %>
     
    <html>
    <head runat="server">
        <title></title>
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
                ArrayList localDrives = new ArrayList();
                foreach (System.IO.DriveInfo drive in drives)
                {
                    if (drive.DriveType == System.IO.DriveType.Fixed)
                    {
                        MyDriveInfo di = new MyDriveInfo();
                        di.Name = drive.Name;
                        di.AvailableFreeSpace = drive.AvailableFreeSpace / 1024m / 1024m / 1024m;
                        di.TotalSize = drive.TotalSize / 1024m / 1024m / 1024m;
                        localDrives.Add(di);
                    }
                }
                GridView1.DataSource = localDrives;
                GridView1.DataBind();
            }
     
            public class MyDriveInfo
            {
                private string _name;
                public string Name
                {
                    get
                    {
                        return _name;
                    }
                    set
                    {
                        _name = value;
                    }
                }
     
                private decimal _availableFreeSpace;
                public decimal AvailableFreeSpace
                {
                    get
                    {
                        return _availableFreeSpace;
                    }
                    set
                    {
                        _availableFreeSpace = value;
                    }
                }
     
                private decimal _totalSize;
                public decimal TotalSize
                {
                    get
                    {
                        return _totalSize;
                    }
                    set
                    {
                        _totalSize = value;
                    }
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <span>Drive Information</span>
            <asp:GridView ID="GridView1"
                runat="server" AutoGenerateColumns="false">
                <%-- Name DriveFormat IsReady AvailableFreeSpace TotalFreeSpace TotalSize VolumeLabel --%>
               <Columns>
                <asp:BoundField DataField="Name" HeaderText="Name" />
                <asp:BoundField DataField="AvailableFreeSpace" HeaderText="AvailableFreeSpace" DataFormatString="{0:n2} g" />
                <asp:BoundField DataField="TotalSize" HeaderText="TotalSize" DataFormatString="{0:n2} g" />
                </Columns>
            </asp:GridView>
        </div>
        </form>
    </body>
    </html>
    --Code End----------------------------------------------------




  • 相关阅读:
    SUSE 安装 iServer、iDesktop启动异常问题
    各系统勒索补丁下载地址
    centos 安装atom 笔记
    转载---SuperMap GIS 9D SP1学习视频播单
    SuSE的命令安装软件 zypper
    Leaflet客户端学习笔记
    设置UI控件的Layer属性(边框可见,边框颜色,边框宽度,边框圆角)
    安全清理Xcode 缓存垃圾
    OC变量命名禁忌
    iOS中的应用启动原理
  • 原文地址:https://www.cnblogs.com/teamleader/p/2411082.html
Copyright © 2020-2023  润新知