Using a broad definition of "file"
ls | wc -l
(note that it doesn't count hidden files and assumes that file names don't contain newline characters).
To include hidden files (except . and ..) and avoid problems with newline characters, the canonical way is:
find . ! -name . -prune -print | grep -c /
Or recursively:
find .//. ! -name . -print | grep -c //