• 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;
    }

  • 相关阅读:
    css问题
    前端性能优化整理
    算法之排序
    浅谈webpack优化
    js设计模式
    事件模型
    浏览器缓存
    ucGUI 12864 从打点起
    ucGUI例程收藏
    Qt 自动搜索串口号列表
  • 原文地址:https://www.cnblogs.com/ArRan/p/4893298.html
Copyright © 2020-2023  润新知