how to calculate term frequency,inverse document frequency(tf-idf) for own text files that consists of many terms.

You can start with computing the term frequencies for each term and every document. There is a snippet by Vegaseat Click Here

Once you have these frequencies, wikipedia has various formulas.

al code run fine for sample text files,but not my text file which i read from my pc

Then you must post the code that you ran together with the error traceback output and may be zip a text file and attach it to your post, so that we can see what's going wrong. We're not soothsayers!