Linked Questions
14 questions linked to/from Directory.GetFiles of certain extension
1 vote
2 answers
4k views
Directory.GetFiles - Search pattern for file extensions [duplicate]
I need to get all ASP files in a folder, so I wrote a code like this: string[] files = Directory.GetFiles(@"C:\Folder", "*.asp", SearchOption.AllDirectories); However, it also returns files with ...
-1 votes
1 answer
131 views
How to most efficiently get all filenames in a list that end with extensions matching those in a predefined array? [duplicate]
Specifically, I have a list of files and an array of compressed file extensions - I am trying to get all the zip files in a folder for later processing. I reviewed a couple other StackOverflow answers ...
0 votes
0 answers
22 views
only continuing process if target file is a pdf [duplicate]
hello all I'm making a process that will import a list of all the files in a given folder for processing. hoever I only want the files to go through the process if they are a PDF so far for importing ...
428 votes
28 answers
545k views
Can you call Directory.GetFiles() with multiple filters?
I am trying to use the Directory.GetFiles() method to retrieve a list of files of multiple types, such as mp3's and jpg's. I have tried both of the following with no luck: Directory.GetFiles("C:\\...
28 votes
1 answer
5k views
creating a constant but local array
Sometimes I need a hardcoded lookup table for a single method. I can create such an array either locally in the method itself static inside the class Example for the first case: public int Convert(...
6 votes
2 answers
16k views
Merging Word documents in folder using c#
I currently have a window-form that when a button is pressed, will merge 3 separate word docx's into one combined file. private void button1_Click(object sender, EventArgs e) { ...
0 votes
3 answers
2k views
Using Directory.GetFiles() to select all the files but a certain extension
I found several questions on Stack Overflow about the Directory.GetFiles() but in all of the cases, they explain how to use it to find a specific extension or a set of files through multiple criteria. ...
3 votes
2 answers
2k views
Is there a way to import PST files into Outlook using C#?
Using: Visual Studio 2017 (Language: C#) I have a similar function written below in PowerShell script, but I need the C# version of it to execute on the click of a button within Visual Studio: Add-...
-3 votes
1 answer
905 views
How to convert files to base 64
I am new to C# and I'm really having a trouble on finding a way to convert files(doc, xlsx, jpg, png, etc.) to base64. So far, what I got is a way to retrieve the path using Directory.GetFiles().......
0 votes
3 answers
728 views
Open all .exe files in a directory c#
I would like to run all the .exe files in a certain directory from my winform application. Is there a way not to hard code the file path of each exe and be not dependent on knowing beforehand how many ...
0 votes
2 answers
425 views
c# exclude file extentions from a foreach statement
I have a foreach statement that is part this function: try { string pathToFiles = sourceTB.Text; DirectoryInfo dirInfo = new DirectoryInfo(pathToFiles); int i = 0; foreach (var files in ...
0 votes
0 answers
453 views
Search Multiple PDFs in a directory for a string in C# using itext7
I am trying to search for text in each PDF inside of a directory using itext7. I can figure out how to search just one PDF. I managed to search one pdf using the below code, how can I make this work ...
0 votes
2 answers
155 views
How can I get the File to be filtered from getFiles() in Visual C#
It's not similar to anything posted on the internet, I am the author of this project that was created some 8 years ago. This project is for my thesis today for my Masteral Degree. I need to improve ...
0 votes
2 answers
97 views
Display filetype from directory in ASP.NET MVC 4 Project
I currently learning about ASP.NET MVC 4. I want to display .cs and .cpp files located in a directory on the web page. But somehow I get exception for multiple file type display. Below line of code ...