Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8992633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:00:10+00:00 2026-06-15T23:00:10+00:00

My origanl DoWork Method was: private static void DoWork(string dirPath) which I called from

  • 0

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";

Code From Here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:00:11+00:00Added an answer on June 15, 2026 at 11:00 pm

    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

     private static void DoWork(string sourceDir, string fileType)
     {
          string[] fileEntries = Directory.GetFiles(sourceDir, fileType, 
                                 SearchOption.AllDirectories);
          foreach (string fullFileName in fileEntries)
          {
                ....
          }
     }
    

    and call it from the Main method in this way

     // Work on every JPG file in source location and subdirectory of the initial location
     DoWork(@"c:\location", "*.jpg");
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this huge VB project which i just got from some one. i
I am using the following PLone + urllib code to proxy responses from another
Method being Tested (In Main Activity) //This Method allows you to set the LeftDrawable
When you append by using an existing content, jQuery will delete the orignal: $(new).append($('#ori'));
I am storing an image locally but my image is store in small size.
Hi I'm trying to override Mage_Customer_AccountController, so that I can extend the createPostAction method.
Hey, I received an learning project from my brother that includes: Create a Drupal
While scaling a panel using a scale transform the application needs to reset the
I am not quite getting the code below right but I have a drop
I'm hosting a WPF control in WinForms using the elementHost control. When I try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.