I am trying to display a list of all files found in the selected directory (and optionally any subdirectories). The problem I am having is that when the GetFiles() method comes across a folder that it cannot access, it throws an exception and the process stops.
How do I ignore this exception (and ignore the protected folder/file) and co...
I have a simple file selector on my web application which uses Directory.GetFiles and Directory.GetDirectories to produce the UI. This works perfectly on my localhost, but when I upload it to my Windows Server 2003 hosting I can only see files - on the same directory, GetFiles works but GetDirectories doesn't.
The code is incredibly si...
Hi all,
Directory.GetFiles method fails on the first encounter with a folder it has no access rights to.
The method throws an UnauthorizedAccessException (which can be caught) but by the time this is done, the method has already failed/terminated.
The code I am using is listed below:
try
{
// looks in stat...
Here is my code,
Dim allFiles As FileInfo() =
tempDir.GetFiles("*.pdf", SearchOption.AllDirectories)
I've googled and found that I need to change the permissions of my app from
Project properties > View UAC Settings > and change level to level="requireAdministrator"
But its also not working. I found somethi...
Hi everyone. I have a folder with far too many files in, and I want to go through each file one by one. The problem is that Directory.GetFiles returns a completed array, and this takes too long.
I would rather have an object I would point to a folder, then call a function that returns me the next file in the folder. Does .NET have a cla...
Edit 6:
Using Windows Integrated authentication (with an account that has access to the share and the database), I can get the list of files/directories. However, refresh the page and get an UnauthorizedAccessException. Perhaps a NetBIOS or ActiveDirectory limitation.
5 months and still no solution, other than 'use impersonation' (via P...
hello
I want to make a script that takes a URL to a file and will import that file to a specific folder in my web server
how to request a file if it's in a passworded area, i have an account "username/password" but how can i make the request to that file ?
...
I know that in the same directory where my code is being executed some files are located. I need to find them and pass to another method:
MyLib.dll
Target1.dll
Target2.dll
Foo(new[] { "..\\..\\Target1.dll", "..\\..\\Target2.dll" });
So I call System.IO.Directory.GetFiles(path, "*.dll"). But now I need to get know the path:
string pa...
Hi,
I've got the following code
files = di.GetFiles("*.jpg");
for (int i = 0; i < files.Length; i++)
{
il.Images.Add(System.Drawing.Image.FromFile(folder + "\\" + files[i].Name));
lv.Items.Add(files[i].Name, i);
}
the code fills a System.Windows.Forms.ImageList with pictures from a jpg files.
it also creates a System.Windows.Fo...
How do you filter on more than one extension?
I've tried:
FileInfo[] Files = dinfo.GetFiles("*.jpg;*.tiff;*.bmp");
FileInfo[] Files = dinfo.GetFiles("*.jpg,*.tiff,*.bmp");
...
i want to write a page that will traverse a specified directory.... and get all the files in that directory...
in my case the directory will only contain images and display the images with their links...
something like this
How to Do it
p.s. the directory will not be user input.. it will be same directory always...
...
In C#, how do I check if a specific file exists in a directory or any of its subdirectories?
System.IO.File.Exists only seems to accept a single parameter with no overloads to search subdirectories.
I can do it with LINQ and System.IO.Directory.GetFiles using the SearchOption.AllDirectories overload, but that seems a bit heavy han...