一个textBox对话框,上面是个文件的路径,例如c:\aaa\b.txt文件  怎么显示这个文件的占用空间的大小?
textBox1.text????朋友们指教,谢谢!

解决方案 »

  1.   

    System.IO.FileInfo fo = new System.IO.FileInfotextBox1.text);
                if (fo.Exists)
                {
                    MessageBox.Show(fo.Length.ToString());
                }
      

  2.   

    不好意思,上面漏了个括号:
    System.IO.FileInfo fo = new System.IO.FileInfo(textBox1.text);
      

  3.   

    假设想要这个路径下的文件的大小<n 怎么写?兄弟!
      

  4.   

    你那么写我编译的话出错,n>fo.length.tostring()????
      

  5.   

    System.IO.FileInfo fi = new System.IO.FileInfo(textBox1.Text.Trim());
                if (fi.Exists)
                {
                    if(fi.Length >= n)
                           MessageBox.Show("File size can't more then n");
                    else
                          ....;
                }
      

  6.   

    int n;
    System.IO.FileInfo fo = new System.IO.FileInfo(path.Trim()); if (fo.Exists)
    {

    n=fo.Length;

    }
     编译不过去 该怎么写??
      

  7.   

    int n;  => long n;
      

  8.   

    你自己去计算字符流不就是你要的吗?
    FileStream fs = new FileStream(handle,*****,****);
    int n ;
    n = (int) fs.Length;