I did a test here with this code and it works, just an example.
Change it to fit what you exactly want.
It is using RESTORE VERIFYONLY you want, the command will check the backup, if it is good it returns 'OK', otherwise it will return the Sql Server error message.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string connectionString1 = (@"Data Source =localhost; Initial Catalog = XXXXXXXXXXXXXXXXXX; Integrated Security = True");
SqlConnection cn = new SqlConnection(connectionString1);
cn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = @"begin try RESTORE VERIFYONLY FROM DISK = 'c:\home\bkp.bak' SELECT 'OK'; end try begin catch select ERROR_MESSAGE(); end catch";
cmd.CommandType = CommandType.Text;
cmd.Connection = cn;
var resultado = cmd.ExecuteScalar();
MessageBox.Show(resultado.ToString());
cn.Close();
}
}