As long as both do what is required "better" becomes largely subjective. However the first version is easier on the eye and easier to understand at first glance
Note though...
- the
System
on
System.AppDomain
is redundant
- declaration of variables is inconsistent
var row
... but
string path
(etc)
-
desImage = string.Empty;
is not actually required (the value is not used)
-
desImage
could be declared within the
foreach
loop
- As TheRealSteveJudge pointed out some of your variable naming could be improved - it is not clear what
desImage
would be for example.
- Formatting in version 2 would make it easier to read e.g. rather than one very long line introduce linefeeds
var ftpfiles = FtpDownload.GetFiles(_newDataTable.Rows[0]["UPSLabelsPath"].ToString(),
_newDataTable.Rows[0]["UPSLabelsPathuid"].ToString(),
_newDataTable.Rows[0]["UPSLabelsPathpwd"].ToString());
The main advantage for me that version 1 has over version 2 is the ease of being able to introduce some validation on the datarow content (which I presume has happened outside this function) - I would probably be doing some null checking etc before diving in to use the data