  We consider the Casimir effect of the electromagnetic field in a higher
dimensional spacetime of the form $M\times \mathcal{N}$, where $M$ is the
4-dimensional Minkowski spacetime and $\mathcal{N}$ is an $n$-dimensional
compact manifold. The Casimir force acting on a planar piston that can move
freely inside a closed cylinder with the same cross section is investigated.
Different combinations of perfectly conducting boundary conditions and
infinitely permeable boundary conditions are imposed on the cylinder and the
piston. It is verified that if the piston and the cylinder have the same
boundary conditions, the piston is always going to be pulled towards the closer
end of the cylinder. However, if the piston and the cylinder have different
boundary conditions, the piston is always going to be pushed to the middle of
the cylinder. By taking the limit where one end of the cylinder tends to
infinity, one obtains the Casimir force acting between two parallel plates
inside an infinitely long cylinder. The asymptotic behavior of this Casimir
force in the high temperature regime and the low temperature regime are
investigated for the case where the cross section of the cylinder in $M$ is
large. It is found that if the separation between the plates is much smaller
than the size of $\mathcal{N}$, the leading term of the Casimir force is the
same as the Casimir force on a pair of large parallel plates in the
$(4+n)$-dimensional Minkowski spacetime. However, if the size of $\mathcal{N}$
is much smaller than the separation between the plates, the leading term of the
Casimir force is $1+h/2$ times the Casimir force on a pair of large parallel
plates in the 4-dimensional Minkowski spacetime, where $h$ is the first Betti
number of $\mathcal{N}$. In the limit the manifold $\mathcal{N}$ vanishes, one
does not obtain the Casimir force in the 4-dimensional Minkowski spacetime if
$h$ is nonzero.
