Questions tagged [directoryinfo]

The .NET DirectoryInfo object contains detailed information about a directory on the filesystem.

The .NET DirectoryInfo object contains detailed information about a directory on the filesystem. It allows you to retrieve properties for a directory such as creation, last access and write times. It also provides the user with the ability to move and delete. Constructed with a directory path, the path does not need to exist when creating a DirectoryInfo instance.

228 questions
56
votes
7 answers

Is there an async version of DirectoryInfo.GetFiles / Directory.GetDirectories in dotNet?

Is there an asynchronous version of DirectoryInfo.GetFiles / Directory.GetDirectories in dotNet? I'd like to use them in an F# async block, and it'd be nice to have a version that can be called with AsyncCallbacks. Problem is I'm trying to suck…
James Moore
  • 8,636
  • 5
  • 71
  • 90
47
votes
5 answers

Directory vs DirectoryInfo

Are they equivalent or alternatives to each other? Is any of them deprecated and if so, which one? Which one is recommended for use in an ASP.NET web application? My aim is to extract all files from a specific directory recursively.
Afshar Mohebi
  • 10,479
  • 17
  • 82
  • 126
25
votes
2 answers

DirectoryInfo.getFiles beginning with

I've come across some strange behavior trying to get files that start with a certain string. Please would someone give a working example on this: I want to get all files in a directory that begin with a certain string, but also contain the xml…
JL.
  • 78,954
  • 126
  • 311
  • 459
21
votes
2 answers

Get path of directoryinfo object

Writing some code in C#, I was wondering if there was a way to get the correct path of a directoryinfo object? Currently I have, for example, a directory such as: DirectoryInfo dirInfo = new DirectoryInfo(pathToDirectory); The issue is that if I…
Giardino
  • 1,367
  • 3
  • 10
  • 30
15
votes
3 answers

.NET - Check if directory is accessible without exception handling

I need to go through various directories on the computer (via DirectoryInfo). Some of them aren't accessible, and UnauthorizedAccessException occurs. How can I check directory access without catching the exception?
SharpAffair
  • 5,558
  • 13
  • 78
  • 158
14
votes
2 answers

Check if directory is accessible in C#?

Possible Duplicate: .NET - Check if directory is accessible without exception handling Im making a small file explorer in Visual Studio 2010 with NET 3.5 and C#, and I have this function to check if a directory is accessible: RealPath=@"c:\System…
user962284
  • 670
  • 1
  • 12
  • 29
13
votes
3 answers

Second path fragment must not be a drive or UNC name - Create Subdirectory Error

I have an exception in the third line ofthis code "Second path fragment must not be a drive or UNC name" DirectoryInfo labdi = new DirectoryInfo(Back.mainfolderpath + @"\news\l"); DirectoryInfo tld = new DirectoryInfo(labdi.FullName + @"\" +…
Saber MalekzadeH
  • 131
  • 1
  • 1
  • 5
12
votes
4 answers

What does @"../.." mean in a path?

I am following this tutorial from MSDN. There's something I saw in the code that I can't understand private void PopulateTreeView() { TreeNode rootNode; DirectoryInfo info = new DirectoryInfo(@"../.."); // <- What does…
Xel
  • 540
  • 2
  • 8
  • 27
12
votes
5 answers

DirectoryInfo, FileInfo and very long path

I try to work with DirectoryInfo, FileInfo with very long path. I try use \\?\c:\long path (i got illegal caracter with fileInfo and DirectoryInfo) I try use file://c:/long path (i got uri not supported) Can i use ~ in a path or something else. I…
Cédric Boivin
  • 10,854
  • 13
  • 57
  • 98
12
votes
2 answers

C#: How to logon to a share when using DirectoryInfo

If I want to instantiate a DirectoryInfo object with an UNC path DirectoryInfo myDI = new DirectoryInfo (@"\\server\share"); how can I pass a username / password that is required to access that share? Thanks
user150898
10
votes
5 answers

C# How can I solve limitations when using DirectoryInfo?

When I recursive through some folders and files, I encounter this error: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directoryname must be less than 248…
Phu Minh Pham
  • 1,025
  • 7
  • 21
  • 38
10
votes
4 answers

Why isn't this DirectoryInfo comparison working?

Possible Duplicate: How to check whether 2 DirectoryInfo objects are pointing to the same directory? var dirUserSelected = new DirectoryInfo(Path.GetDirectoryName("SOME PATH")); var dirWorkingFolder = new DirectoryInfo(Path.GetDirectoryName("SAME…
baron
  • 11,011
  • 20
  • 54
  • 88
8
votes
4 answers

DirectoryInfo.Delete(True) Doesn't Delete When Folder Structure is Open in Windows Explorer

Assuming I have a folder structure like: C:\MyTemp - MySubFolder If I try to delete this using: Dim path As String = "C:\MyTemp" Dim di As System.IO.DirectoryInfo di =…
Todd Main
  • 28,951
  • 11
  • 82
  • 146
7
votes
2 answers

Append and write access to a Directory — FileIOPermission give not good result?

I have one issue which is in fact solved, but I totally do not understand why it behaves like this. So I have a network share and I would like simply to verify if I have access to create new files and directories in that share. I have used two…
user2323704
  • 853
  • 1
  • 7
  • 13
7
votes
1 answer

Get full path to file while debugging using IIS Express

I have a .NET application that I am trying to debug and part of my application loads a file from my project. This file is located at C:\Users\USER_FOLDER\Documents\Visual Studio 2012\Projects\MY_PROJECT\_templates\myFile.html In my code, I specify…
Anil
  • 2,539
  • 6
  • 33
  • 42
1
2 3
15 16