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

  • Home
  • SEARCH
  • 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 8306813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:24:18+00:00 2026-06-08T18:24:18+00:00

for (int i = 0; i < PrefixDistinctCount; i++) { string FirstPolicy = ;

  • 0
for (int i = 0; i < PrefixDistinctCount; i++)
                {
                    string FirstPolicy = "";

                    FirstPolicy = OriginalPics[0].ToString().Substring(26, 7);

                    var SamePoliciesQuery = OriginalPics.Where(x => Path.GetFileName(x).StartsWith(FirstPolicy));

                    foreach (string picture in SamePoliciesQuery)
                    {
                        File.Move(picture, AppVars.ProcessingPolicyImagesDirectory + picture.Substring(26, 12) + ".jpg");
                    }

                    string[] SamePolicyPics = Directory.GetFiles(AppVars.ProcessingPolicyImagesDirectory);
                    GenerateTiffFile(SamePolicyPics);

                    Directory.Delete(AppVars.ProcessingPolicyImagesDirectory, true);
                    Directory.CreateDirectory(AppVars.ProcessingPolicyImagesDirectory);

                    OriginalPics = Directory.GetFiles(SelectedDirectory);
                }

Towards the end where it says “Directory.Delete(AppVars.ProcessingPolicyImagesDirectory, true);” i’m getting an error that it’s not allowing me to delete the file. I’m GUESSING it’s because something in the code is not closing the file or what not. does anyone know what could be the case? or how I would go about using “using” to fix this problem?

IOException was unhandled. The process cannot access the file ‘blah blah’ because it is being used by another process.

This is the code for GenerateTiffFile –

public void GenerateTiffFile(string[] SamePolicyPics)
        {
            ImageCodecInfo info = null;
            foreach (ImageCodecInfo ice in ImageCodecInfo.GetImageEncoders())
                if (ice.MimeType == "image/tiff")
                    info = ice;

            Encoder enc = Encoder.SaveFlag;

            EncoderParameters ep = new EncoderParameters(1);
            ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.MultiFrame);

            Bitmap pages = null;

            int frame = 0;

            foreach (string picture in SamePolicyPics)
            {
                if (frame == 0)
                {
                    pages = (Bitmap)Image.FromFile(picture);
                    //pages.Save(picture.Substring(0, picture.Length - 3) + "tiff", info, ep);
                    pages.Save(AppVars.FinalPolicyImagesDirectory + picture.Substring(29, 7)  + ".tiff", info, ep);
                }
                else
                {
                    ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.FrameDimensionPage);
                    Bitmap bm = (Bitmap)Image.FromFile(picture);
                    pages.SaveAdd(bm, ep);
                }

                if (frame == SamePolicyPics.Length - 1)
                {
                    ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.Flush);
                    pages.SaveAdd(ep);
                }
                frame++;
            }
        }
  • 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-08T18:24:18+00:00Added an answer on June 8, 2026 at 6:24 pm
    using(Bitmap pages = (Bitmap)Image.FromFile(SamePolicyPics[0])){
            int frame = 0;
    
            foreach (string picture in SamePolicyPics)
            {
                if (frame == 0)
                {
                    pages.Save(AppVars.FinalPolicyImagesDirectory + picture.Substring(29, 7)  + ".tiff", info, ep);
                }
                else
                {
                    ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.FrameDimensionPage);
                    using(Bitmap bm = (Bitmap)Image.FromFile(picture)){
                        pages.SaveAdd(bm, ep);
                    }
                }
    
                if (frame == SamePolicyPics.Length - 1)
                {
                    ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.Flush);
                    pages.SaveAdd(ep);
                }
                frame++;
            }}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

int numcells = 2; foreach (System.IO.FileInfo fi in fileQuery) { Label1.Text = fileList.Count().ToString(); TableRow
int filesize(FILE * handle) { int filesize; int old_pointer = ftell(handle); fseek(handle, 0, SEEK_END);
int i; i=0; for (i=0;i>2;i++) { repeat((3),|,var); printf(\n); } For some reason it gets
int a = 2; Console.WriteLine(a.ToString()); // displays 2 // definition of ToString() here -
int ungetc(int c, FILE *fp) pushes the character c back into fp, and returns
int countConsonant(string str, int consonant) { int length = str.length(); consonant = 0; for
int main(void) { char tmp, arr[100]; int i, k; printf(Enter a string: ); scanf_s(%s,
int queryVector = 1; double similarity = 0.0; int wordPower; String[][] arrays = new
int a = 10; int* pA = &a; long long b = 200; long
int main(void) { char testStr[50] = Hello, world!; char revS[50] = testStr; } I

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.