My origanl DoWork Method was:
private static void DoWork(string dirPath)
which I called from my Main Method using:
DoWork(@"C:\location");
But I’ve changed the DoWork method to the following.
private static void DoWork(string sourceDir, string fileType)
I’m stumped how to call this from my main method, I am new to c# and have looked at the MSDN site but for some insight but I can’t seem to find anything to relate to my issue. Any guidance would be appreciated.
Snippet from my DoWork method:
private static void DoWork(string sourceDir, string fileType)
{
// Function: Get specified files (fileType) form sub-directory (sourceDir)
// Return: void
{
string[] dirEntries = Directory.GetDirectories(@"c:\fileDump");
string fileName, filePath, fullFileName;
foreach (string subDir in dirEntries)
{
DirectoryInfo dir = new DirectoryInfo(subDir);
FileInfo[] imgFiles = dir.GetFiles("*.xml");
foreach (FileInfo imgFile in imgFiles)
{
fileName = imgFile.Name;
filePath = imgFile.DirectoryName;
fullFileName = "filePath + “\\” + fileName";
So, I suppose, you want to call a method that works only on certain kind of files.
Then your code should be something like this
and call it from the Main method in this way
The Directory.GetFiles method could take three arguments that specify the source location, the file pattern to match files and an enum that triggers a recursive search of all subfolders of the initial folder.