通过FileInfo.Length 属性来获取

解决方案 »

  1.   

    下面的示例显示指定文件的大小。// The following example displays the names and sizes
    // of the files in the specified directory.
    using System;
    using System.IO;public class FileLength
    {
        public static void Main()
        {
            // Make a reference to a directory.
            DirectoryInfo di = new DirectoryInfo("c:\\");
            // Get a reference to each file in that directory.
            FileInfo[] fiArr = di.GetFiles();
            // Display the names and sizes of the files.
            Console.WriteLine("The directory {0} contains the following files:", di.Name);
            foreach (FileInfo f in fiArr)
                Console.WriteLine("The size of {0} is {1} bytes.", f.Name, f.Length);
        }
    }
      

  2.   

    DirectoryInfo di = new DirectoryInfo("c:\\");
    我是让别人上传图片,这个路径怎么写?
      

  3.   

    即使是别人上传,也应该由你来规定上传位置吧DirectoryInfo di = new DirectoryInfo("你设定的上传目录");