Questions tagged [system.io.fileinfo]

77 questions
0
votes
1 answer

GetFiles is incredibly slow vb.NET

I need to process a large amount of files and scour thru a group of directories and subdirectories and get the file from the found directory. This is easy using a simple directory but when scouring a thousand directories, the program slows down to a…
0
votes
0 answers

DirectoryInfo.EnumerateFiles() result is empty on Ubuntu

I am looking at System.IO and wrote a small method to count the number of files in a directory. The problem I have is that when I debug this piece of code in windows, I can enumerate over the collection when I hover over the collection. So here is…
0
votes
0 answers

System.IO.FileAttributes is not the same as the enum type System.Reflection.PropertyAttributes in C# /SSIS

I'm trying to identify whether the content inside a fileinfo object is a directory and if not I need to add them in a stack. I'm trying with the below code but getting the subjected error in the "IF condition" not sure how to proceed from here. Any…
Gowtham Ramamoorthy
  • 896
  • 4
  • 15
  • 36
0
votes
0 answers

Determining if a PDF only has a header and footer in C#

Is there a definitive way to check an existing PDF for only the header and footer to be populated? I run a console app that merges existing PDFs together into a single PDF (FileA.pdf, FileB.pdf and FileC.pdf become FileABC.pdf). The caveat is that…
0
votes
1 answer

Parametrized List.Cast with parametrized initialization

There are a lot of methods to convert a string/List to a list of something else. Out of curiosity I can't find if there is a way to do it this way Directory.EnumerateFiles(@"C:\Drivers").ToList(); Or Either new…
Liquid Core
  • 1
  • 6
  • 27
  • 52
0
votes
2 answers

c# System.IO how do i find all the subfolders given a certain folder?

This is what I've done so far: class Program { static void Main(string[] args) { DirectoryInfo startDirectory = new DirectoryInfo(@"C:\Users\Angelo\Desktop\ExerciseTest"); string output = ""; DirectoryInfo[]…
user8918999
0
votes
1 answer

Sort List using Filename

i have a program where i need to list the files in my Listbox like the way windows Sort the files i have this code but it doesn't sort the Files properly public ObservableCollection FileNames { get; } = new ObservableCollection(); …
outlook email
  • 361
  • 1
  • 3
  • 14
0
votes
3 answers

Filename ending with period and using FileInfo C#

I'm having an issue where a file containing a period at the end of its name cannot be seen by FileInfo. I know that Windows prevents naming files this way, but this data came from a different operating system. I am able to create a problem file in…
complhex
  • 31
  • 2
0
votes
2 answers

Can't get around IOException error: Cannot access the file

I am having a hard time trying to figure out this IOException. This method used to work flawless until about two months ago. The only change I have made to it was moving the parsed file to another folder, which also worked for awhile. Now every time…
Obie_One
  • 81
  • 10
0
votes
0 answers

An infinity loop during recursive directory search in c#

I'm trying to make a code in c# that prints all file directories in my computer, and I'm almost there. But a problem exists: When a folder name is just a space (" ") the process goes into an infinite loop. What do you advise me to do, without…
0
votes
1 answer

Why I can't rename my files and folders?

So I am re writing a routine to rename stuff. My Folder tree structure looks similar to this: Folder -> Folder(s) -> Folder(s) + ImageFile(s) Session -> Location(s) -> Test(s) + Images All locations have the same Tests and renaming one must…
Khalil Khalaf
  • 9,259
  • 11
  • 62
  • 104
0
votes
0 answers

How to share app.config SQL Connection String between projects

I have a set of projects (e.g., For DataProvider, Tests and Main). I'm getting a SQL connection string from my app.config file using ConfigManager. When I need to use this connection string in project other than Main, currently I need to…
mikroice90
  • 137
  • 1
  • 9
0
votes
1 answer

How to Convert Binary file data to a physical type with a given MIME Type

I have a database table (tbl_document) which contains details of files which were uploaded into it over time. I want to write a console application to download these files to a given location. The table has three pieces of information, which I…
t_plusplus
  • 4,079
  • 5
  • 45
  • 60
0
votes
1 answer

Copy file fo mapped network drive using FileInfo.CopyTo

I try to copy a file to a mapped network drive, but I always get the message "Could not find a part of the path ...". I tried different mapped network drives, so I could exclude credential problems (it neither works with a drive connexcted with…
Azrael
  • 385
  • 2
  • 5
  • 13
0
votes
0 answers

File.Open doesn't throw IOException for already open file

This always returns false regardless of whether file is already open or closed. It worked fine until yesterday; today it doesn't work as expected. public bool isOpen(FileInfo file) { FileStream stream = null; try { stream =…