Constructing file paths for each row of a datatable in C#
One simple trick here would be to take the column processing outside of the row processing (the column metadata should not change while the rows probably will):

using (var metadaDataTable = GetMetaDataTable())
{
    var columns = metadaDataTable.Columns
        .Cast&lt;DataColumn&gt;()
        .Where(col =&gt; col.ColumnName != "path_variable")
        .ToList();
    var path_variable = metadaDataTable.Columns
        .Cast&lt;DataColumn&gt;()
        .SingleOrDefault(col =&gt; col.ColumnName == "path_variable");
    string path_variable_value;

    foreach (var row in metadaDataTable.Rows.Cast&lt;DataRow&gt;())
    {
        var newfileName = columns.Aggregate(string.Empty, (current, col) =&gt; current + (row[col] + "_"));

        newPath = CleanFileName(newfileName);
        path_variable_value = path_variable == null ? null : row[path_variable].ToString();
        // TODO: do something with the path_variable_value before continuing the loop.
    }
}


Note also I've sprinkled a liberal amount of LINQ in there to signify intent rather than mechanism.

Finally, Also surrounded the lifetime of metaDataTable with a using construct as DataTable implements the IDisposable interface.