Ghani made the remarks at Special Operations Command Center in Kabul. "The government will never allow this to happen," President Ghani said.
Ghani pledged to provide "any kind of support," for Afghan special operations forces, Tolo News reported.
He promised to address the needs of families of the security force members who have lost their lives while serving their country.
"Our goal is to protect Afghanistan, freedom, equality and the achievements of the last 20 years, but the intention of the enemy is dark," Ghani said, "and you prove to the enemy they will take their dreams to the grave."
Ghani said Afghanistan's decision to send a high-ranking delegation to Doha for negotiations was to determine the Taliban's will for peace.
"The Taliban made clear many things. Abdullah told me some minutes ago that there is no will for peace among the Taliban. We sent the delegation ... to show that we have the will for peace and we are ready for sacrifice for it, but they (Taliban) have no will for peace and we should make decisions based on this," Ghani said.
Ghani said this Eid has been dedicated to Afghan forces to honour their sacrifices and courage, especially in the last three months.
"Afghanistan's security and defence forces have made many sacrifices in the last 20 years, especially in the last three months, to defend this soil and honour this homeland," Ghani said.
Afghanistan is witnessing a surge in violence as the Taliban has intensified its offensive against civilians, Afghan defence and security forces as foreign forces are withdrawing from the war-torn country.
As the Taliban have taken control of several districts across the country, US intelligence assessments earlier have suggested the country's civilian government could fall to the terror group within months of US forces withdrawing.
Thousands of families have been displaced following the surge in violence amid the Taliban offensive against civilians and security forces in Afghanistan.
Meanwhile, Afghan officials have accused Pakistan of extending support to Taliban terrorists and providing safe haven to them.