C # Check if there is File then [closed]

-2

Good afternoon, I have a code that cleans notepad, writes to another notepad and inserts into the database, but now I need it to check if there is another file with the same name and if it is recent, do the update, but I do not know how I can do it, if anyone can give me a Light I would appreciate: D

 public void Consultar()
    {
        using (SqlConnection conn = new SqlConnection(@"Password=*******;Persist Security Info=True;User ID=sa;Initial Catalog=DashboardCBA;Data Source=SCAN-D-50985\SQL"))
        {
            using (SqlCommand cmd = new SqlCommand("SELECT * FROM [dbo].[TableCSV] where NomeArquivo = @NomeArquivo", conn))
            {
                var NomeArquivo = Carteira_Vendas;
                cmd.Parameters.AddWithValue("NomeArquivo", NomeArquivo);
                conn.Open();
                object o = cmd.ExecuteScalar();
                if (o != null)
                {
                    int total = Convert.ToInt32(o);
                    if (total > 0)
                    {
                        var FlagAtivo = 1;
                        cmd.Parameters.Clear();
                        cmd.CommandText = "UPDATE [dbo].[TableCSV] SET NomeArquivo=@NomeArquivo, FlagAtivo='"+ FlagAtivo+"' ";
                        cmd.Parameters.AddWithValue("@NomeArquivo", NomeArquivo);
                        cmd.ExecuteNonQuery();
                    }
                    else
                    {
                        GravarBanco();
                    }
                }
            }
        }

* EDIT: Here's what I did to solve it.

    
asked by anonymous 04.01.2019 / 18:03

0 answers