#include<iostream.h>//C++显示(读取)文件大小源程序
#include<fstream.h>
void main()
{
    ifstream rs("E:\\visual studio 2008\\Projects\\libraryManger\\libraryManger\\book.txt",ios::in);
    try
    {
        if(rs.fail())
        //当文件不存在时,rs.fail()返回真
            throw "error!";
    }
     catch(char *s)
    {
       // cout<<s<<fname<<"文件不存在!"<<endl;
        cout<<s<<"文件不存在!"<<endl;
        return;
    }
    rs.seekg(0,ios::end);
    //此句意为将文件的读指针移至文件末尾
    cout<<"文件大小:"<<rs.tellg()<<"Bytes"<<endl;
    //tellg()函数返回当前文件指针的位置
}