Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot delete file because it is being used by another process
    primarykey
    data
    text
    <pre><code>for (int i = 0; i &lt; PrefixDistinctCount; i++) { string FirstPolicy = ""; FirstPolicy = OriginalPics[0].ToString().Substring(26, 7); var SamePoliciesQuery = OriginalPics.Where(x =&gt; 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); } </code></pre> <p>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?<br></p> <p>IOException was unhandled. The process cannot access the file 'blah blah' because it is being used by another process.</p> <p>This is the code for GenerateTiffFile -</p> <pre><code>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++; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload