There is another option, called A.C.T.S. you can get debt relief without destroying your credit, considering the situation you are in I would be happy to explain it to you in detail. Please message me privately @ firstname.lastname@example.org.
Bankruptcy may delay but not stop foreclosure.
Bankruptcy is complicated and the advice of a bankruptcy attorney is absolutely necessary if that is a path that you want to contemplate.
If you can not get a loan modification and you can not make the payments on your home declaring bankruptcy may help you stay in your home a little while longer, but it will not erase your mortgage and does have long term consequences. You can also look into a short sale which would be better for your credit but does not allow you to keep your home.
If you are thinking of bankruptcy you should contact a lawyer who specializes in bankruptcies who will help you understand all of the ramifications.
Keller Williams REalty
Maybe you can ask friends for a referral to a real estate agent or real estate attorney they trust.
Best wishes to you.