Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check whether a folder exists in a path in c#?

Tags:

c#

directory

How to check whether a folder named RM exists inside a directory...I have given the directory path through textbox like txtBoxInput.Text and in this path i have to check...Any suggestion?

like image 760
bala3569 Avatar asked Dec 22 '10 13:12

bala3569


People also ask

How do you check if a path is a directory in C?

The isDir() function is used to check a given file is a directory or not. Here we used stat() function and S_ISREG() macro. In the main() function, we created a character array fileName. Then we read the name from the user.

How do you check if a folder exists or not?

$Folder = 'C:\Windows' "Test to see if folder [$Folder] exists" if (Test-Path -Path $Folder) { "Path exists!" } else { "Path doesn't exist." } This is similar to the -d $filepath operator for IF statements in Bash. True is returned if $filepath exists, otherwise False is returned.

Does directory exist C++?

Call DirectoryExists() to determine whether the directory specified by the Directory parameter exists. If the directory exists, the function returns True. If the directory does not exist, the function returns False.

How do you create a directory in C?

This task can be accomplished by using the mkdir() function. Directories are created with this function. (There is also a shell command mkdir which does the same thing). The mkdir() function creates a new, empty directory with name filename.


1 Answers

Path.Combine and Directory.Exists ?

http://msdn.microsoft.com/en-us/library/system.io.path.combine.aspx

http://msdn.microsoft.com/en-us/library/system.io.directory.exists.aspx

if (Directory.Exists(Path.Combine(txtBoxInput.Text, "RM"))
{
    // Do Stuff
}
like image 108
Steven Robbins Avatar answered Sep 28 '22 08:09

Steven Robbins