Bankruptcy Law Questions? Ask a Bankruptcy Lawyer.
Filing bankruptcy will not prevent foreclosure - it will only delay the foreclosure. IF you were to file bankruptcy, the mortgage company has the right to request the bankruptcy court to release the house/collateral to it in order to foreclose. This request is always granted. Once the bankruptcy court releases the house, the lender will institute foreclosure proceedings.
Also, there is an expense with filing bankruptcy and will encompass everything you own or owe for - not just the house.
Thus, if the entire issue is the house, you should just allow it to be foreclosed or see if the lender will accept a deed in lieu of foreclosure. This allows you to avoid the foreclosure process by voluntarily deeding the property back to the lender - it also prevents the lender from seeking a deficiency judgment against you. However, it is the lender's option as to whether it accepts this - it usually will if it believes the house will bring at least what is owed on the home.