Firstly, I am most comfortable coding in Java. I am creating an application in C# as a learning tool. In this app I am calling a method from a Click Event Method.
private void btnViewFile_Click(object sender, EventArgs e) {
GetFileNames();
lblOutputPath.Text = sb;
}
private StringBuilder GetFileNames() {
StringBuilder sb = new StringBuilder();
string[] fileNames = Directory.GetFiles(Dir);
foreach (string s in fileNames)
sb.Append(s);
return sb;
}
I want to break out the code that gets the FileNames of each file in the directory out of the Click method to keep it more modularized. I would get a value for the StringBuilder object and then pass it back into the Click event method.
That's how I would do it in Java at any rate. Is this an effective tack or is there a better way to do this?