Consider the magnetic field caused by a long, straight conductor carrying a current I:
$$B = \frac{\mu_{0} I}{2 \pi r}$$
Let’s consider $\oint \vec{B}.d\vec{l}$ of the very same magnetic field.
$$\begin{aligned} \oint \vec{B}.d\vec{l} &= \int\limits_{0}^{2 \pi} Br \, d \theta \\ &= Br \int\limits_{0}^{2 \pi} \, d\theta \\ &= B \times 2 \pi r \end{aligned}$$
Notice that we can substitute the result into the first equation. Hence,
$$\oint \vec{B}.d\vec{l} = \mu_{0}I$$
The line integral is independent of the radius of the circle and is equal to $\mu_{0}$ multiplied by the current passing through the area bounded by the circle.
Suppose now that the integration path goes around the circle in the opposite direction.
$$\begin{aligned} \oint \vec{B}.d\vec{l} &= \, \int\limits_{0}^{2 \pi} Br \, d\theta \\ &= \, – Br \int\limits_{0}^{2 \pi} \, d\theta \\ &= \, – B \times 2 \pi r \end{aligned}$$
We will obtain:
$$\oint \vec{B}.d\vec{l} = \, – \mu_{0} I$$
The line integral equals $\mu_{0}$ multiplied by the current passing through the area bounded by the integration path, with a positive or negative sign depending on the direction of current relative to the direction of integration.
Consider an integration path that does not enclose the conductor:
$$\begin{aligned} \oint \vec{B}.d\vec{l} &= \int\limits_{a}^{b} \vec{B}.d\vec{l} + \int\limits_{b}^{c} \vec{B}.d\vec{l} + \int\limits_{c}^{d} \vec{B}.d\vec{l} + \int\limits_{d}^{a} \vec{B}.d\vec{l} \\ &= \int\limits_{a}^{b} Br_{1} \, d\theta + 0-\int\limits_{c}^{d} B4_{2} \, d\theta + 0 \\ &= \frac{\mu_{0}I}{2 \pi r_{1}} r_{1} \int\limits_{a}^{b} \, d\theta \, – \frac{\mu_{0}I}{2 \pi r_{2}}r_{2} \int\limits_{c}^{d} \, d\theta \\ &= 0 \end{aligned}$$
Even though there is a magnetic field everywhere along the integration path, the line integral is zero as there is no current passing through the area bounded by the path.
The results above are independent of the shape of the path or the position of the wire inside it.
When several long, straight conductors pass through the surface bounded by the integration path, the current in the equation will just be the net enclosed current.
We shall restate Ampere’s Law:
$$\oint \vec{B}.d\vec{l} = \mu_{0}I_{encl}$$
,which is valid for conductors and paths of any shape.
Ampere’s Law states that for any closed loop path, the sum of the length elements times the magnetic field in the direction of the length element is equal to the permeability ($\mu_{0}$) times the electric current enclosed in the loop.
Note: If you are not convinced that it is valid for conductors and paths of any shape, you can pick up any undergraduate EM textbooks. The mathematics used here is too primitive to enable easy proving of Ampere’s law for conductors and paths of any shape.
Next: Applications Of Ampere’s Law