Set up a package with Needs[]?

By steps Insert/FilePath, I got a file path:
“D:\Mathematica\Mathematica Programer II\MATHPROG\LOGICPROGRAMMING.M”,
but

Needs["D:\\Mathematica\\Mathematica Programer \
II\\MATHPROG`LOGICPROGRAMMING.m`"]

Mathematica always says

    Needs::cxt: Invalid context specified at position 1 in
 Needs[D:\Mathematica\Mathematica Programer II\MATHPROG`LOGICPROGRAMMING.m` ]. 
A context must consist of valid symbol names separated ` 

In fact I put `, What’s wrong?

The first argument of Needs is not the path, but the context. You can give the path as second argument. Something like this:

Needs["MATHPROG`LOGICPROGRAMMING", "D:\\Mathematica\\Mathematica \
Programer II\\MATHPROG`LOGICPROGRAMMING.m`"]

but you will probably have to retype the context and path. You can use Get with the path only.


Thanks!![](http://community.wolfram.com//c/portal/getImageAttachment?filename=Needs.jpg&us)
But still failed, running see result image.

Mathematica sometimes does run when code meet their syntax!

you need to add a prime at the end of the context name, and delete it from the file name:

Needs["MATHPROG`LOGICPROGRAMMING`", "D:\\Mathematica\\Mathematica \
Programer II\\MATHPROG`LOGICPROGRAMMING.m"]

Also, are you sure your context in the .m file is in all capital letters like that? – make sure to match the case of the Begin[…] in the .m file.

Got it !(See below run result.)
In fact, all the packages and the files in the directory, hold CAPITAL LETTERS. However, inner the files.m , the self-names are stated in lower case like MathProg, LogicProgramming.m. Now I transformed all in lowercase, and run successfully.
Thank you very much for your help ![enter image description here][1]