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 8303373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:30:54+00:00 2026-06-08T17:30:54+00:00

Currently I am writing the windows service to process massive xml files and save

  • 0

Currently I am writing the windows service to process massive xml files and save info from xml file to database. There are 3 machines running the same services that point to the same share location. I always got exception that File Not Found during the process and don’t know how to solve this problems. I tried to get all file from the directory and rename those files based on the machine name and allow each machine to process it own set of files but still suffer from File Not Found exception. Could anyone show me the proper way to deal with this.

Thank you.

Code

if (Directory.Exists(folder))
{
  string pattern = ".xml";
  string machineName = System.Environment.MachineName;
  string[] files = Directory.GetFiles(folder, pattern, SearchOption.AllDirectories);  
  newExt = string.Format("{0}.{1}", machineName, newExt);
  for (int i = 0; i < files.Length; i++)
  {
      if (files[i].Contains(machineName))
      {
           //replace this new extension
           files[i].Replace(machineName + ".", "");
      }
      else
      {
           files[i] = ChangeExtension(files[i], newExt, true);
      }
  }
  IEnumerable<string> sortedFiles = files.Where(f => !string.IsNullOrEmpty(f) && f.Contains(machineName))
                                         .OrderBy(f => f, Sorter);
}
  • 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-08T17:30:56+00:00Added an answer on June 8, 2026 at 5:30 pm

    Could you, please, explain with what names files appear in the directory?

    1. If files already have the target machinename in their names it is enough for each machine to process only those named files (or not??).
    2. If files appear without any special machinename specified, it looks like a race among the working services, who captures a file first. Then your exception seems to be expectable (just as Eric J. said), and you’d just try..catch it and omit the file. It is normall and some other service has already captured that file. Or you could think over some resource sharing technique to avoid several services to check the directory at once time. At least you could make some subdirectories to divide all files into some groups and make each service work with each subdirectory…

    P.S.: surely, if you feel, that I failed to catch the issue, could you, please, provide some more accurate info.

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

Sidebar

Related Questions

I'm writing a program that parses the log files of a Windows service. The
I am currently writing a little windows service application and I can successfully in/uninstall
I'm writing a windows service that might delete a file at some point. Because
I’m currently writing a windows service that’s sole purpose in life is to poll
I'm currently writing a Windows Explorer Shell Extension. Everything is ok so far but
I'm currently writing a function what would create a zip file, which will be
I'm currently writing a Powershell script that's used to select a user from Active
I'm writing a Windows Service for communication with a Serial Mag-stripe reader and a
The situation I'm in is this - there's a process that's writing to a
I'm writing a Windows service which starts a TCP listener. The core code works

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.