How do I delete all image files with same album id?
<p>I have a two tables, one with all the pictures (called billeder, its danish), that have foreign key (in my code called 'album') that tells witch album it belongs to, and then I have the one with albums, with the primary key (alb_id). So i can eval the pictures from an specific album.</p>

<p>I know how to delete a picture, both in the table and in the folder on the server. That works fine.</p>

<p>But I need to know how to delete all of the pictures in the folder at once.</p>

<p>I have this so far:</p>

<pre><code>  SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ToString());

    SqlCommand cmd = new SqlCommand();

    cmd.Connection = conn;


    cmd.CommandText = "DELETE FROM albums WHERE alb_id = @id";
    cmd.Parameters.AddWithValue("@id", id);

    conn.Open();  // Open the connection
    cmd.ExecuteNonQuery();
    conn.Close();

    cmd.CommandText = "DELETE FROM billeder WHERE album = @id";
    cmd.Parameters.AddWithValue("@id", id);

    conn.Open();  // Open the connection
    cmd.ExecuteNonQuery();
    conn.Close();
</code></pre>

<p>The code i have for deleting the file:</p>

<pre><code>   File.Delete(Server.MapPath("../fotos/" + image));
</code></pre>