Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# check if string is path or file

// get the file attributes for file or directory
FileAttributes attr = File.GetAttributes(@"c:Temp");

//detect whether its a directory or file
if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
    MessageBox.Show("Its a directory");
else
    MessageBox.Show("Its a file");
Comment

how to check if a path is a directory or file c#

// get the file attributes for file or directory
FileAttributes attr = File.GetAttributes(@"c:Temp");

if (attr.HasFlag(FileAttributes.Directory))
    MessageBox.Show("Its a directory");
else
    MessageBox.Show("Its a file");
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# timer 
Csharp :: .net core check if user is logged in 
Csharp :: how to pause code execution in c# 
Csharp :: json.net deserialize dynamic 
Csharp :: write text files with C# 
Csharp :: csproj include folder and files 
Csharp :: unity chat system 
Csharp :: How to get an array of months in c# 
Csharp :: unity create gameobject 
Csharp :: how to make an object appear and disappear in unity 
Csharp :: how to make multiplayer game in unity 
Csharp :: .net Core Return File like File Server 
Csharp :: c# create array 
Csharp :: c# listbox delete selected items 
Csharp :: c# create object with properties 
Csharp :: increase timeout in .net core web app 
Csharp :: parse json array c# 
Csharp :: randomm number from 2 different ranges 
Csharp :: c# list tuple 
Csharp :: unity log warning 
Csharp :: distinct prime factors count of a number 
Csharp :: xamarin forms open new page on button click 
Csharp :: c# get type of object 
Csharp :: unity instantiate prefab rotation 
Csharp :: c# insert character into string at position 
Csharp :: c# get char from string 
Csharp :: c# how to call a method from another class 
Csharp :: c# find substring in string 
Csharp :: csharp datagridview filter column 
Csharp :: c# OrderBy desc 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =