zoukankan      html  css  js  c++  java
  • C# 文件大小

      

    /// <summary>
    /// 获取文件大小
    /// </summary>
    /// <param name="sFullName"></param>
    /// <returns></returns>
    public static long TGetFileSize(string sFullName)
    {
    long lSize = 0;
    if (File.Exists(sFullName))
    lSize = new FileInfo(sFullName).Length;
    return lSize;
    }

    public string GetFileSize(string sFileFullName)
    {
    FileInfo fiInput = new FileInfo(sFileFullName);
    double len = fiInput.Length;

    string[] sizes = { "B", "KB", "MB", "GB" };
    int order = 0;
    while (len >= 1024 && order + 1 < sizes.Length)
    {
    order++;
    len = len / 1024;
    }

    string filesize = String.Format("{0:0.##} {1}", len, sizes[order]);
    return filesize;
    }

    public static bool FileIsLargerThan1KB(string sFileFullName)
    {
    FileInfo fiInput = new FileInfo(sFileFullName);
    double len = fiInput.Length;

    len = len / 1024 / 1024;
    return len > 1;
    }

  • 相关阅读:
    爬虫示例
    S20_DAY23--课堂笔记
    python--常用模块之正则
    S20_DAY22--课堂笔记
    win10系统重装
    CCF 命令行选项
    CCF 任务调度
    CCF 出现次数最多的数
    CCF ISBN
    CCF 最大的矩形
  • 原文地址:https://www.cnblogs.com/ArRan/p/4893298.html
Copyright © 2011-2022 走看看