yamid

yamid

  • NA
  • 98
  • 0

Get some files with an extension in a directory with C#

Apr 20 2014 3:53 PM
I have a directory with many files where many of them have the same name with different extension. I want a C# code to search the directory and to get only the files with extension ".jpg" if the same file name with extension ".pdf" DOES NOT exists.
Example: In my directory I have these files:
"A.jpg"
"A.pdf"
"A.png"
"B.jpg"
"B.png"
"C.jpg"
"C.pdf"
"C.docx"
"D.pdf"
"E.jpg"
"F.jpg"
"F.pdf"
"F.docx"

The code should search this directory and get all the .jpg files if its .pdf file doesn't exist. therefore the code should give this files:
{"B.jpg", "E.jpg"}.

Thank you


Answers (1)