SlideShare a Scribd company logo
1 of 11
Directory Class
in
C #
Directories….
Telephone directory….??
Directory Class in C #
Let’s See….
Directory Class
1. Deals with Directories and Sub-Directories.
2. Using System.IO
3. Static in Nature.
4. No Instantiation Required.
5. It Cannot be Inherited.
Methods:
Name Description
CreateDirectory(String) Creates all directories and subdirectories in the specified
path unless they already exist.
CreateDirectory(String,
DirectorySecurity)
Creates all the directories in the specified path, unless
the already exist, applying the specified Windows
security.
Delete(String) Deletes an empty directory from a specified path.
Delete(String, Boolean) Deletes the specified directory and, if indicated, any
subdirectories and files in the directory.
EnumerateDirectories(String) Returns an enumerable collection of directory names in a
specified path.
Exists Determines whether the given path refers to an existing
directory on disk.
Move Moves a file or a directory and its contents to a new
location.
GetCurrentDirectory Gets the current working directory of the application.
SetCurrentDirectory Sets the application's current working directory to the
specified directory.
GetLastAccessTime Returns the date and time the specified file or directory
was last accessed.
Remarks:
 Efficient to perform One directory-related action.
 The static methods of the Directory class perform security
checks on all methods.
 Make Use of DirectoryInfo instance methods if we want to
reuse objects several times.
 The security check will not always be necessary.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
namespace DirectoryExample
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("n**************************************************
*******n");
Console.WriteLine("tt DIRECTORY EXAMPLE:");
Console.WriteLine("n**************************************************
*******n");
if (Directory.Exists("c:testDir1"))
{
//Shows Message If testdir1 Exists
Console.WriteLine("t Directory 'testDir' Exist ");
}
else
{
// Create The Directory testDir1
Directory.CreateDirectory("C:TestDir1");
Console.WriteLine("t Directory: TestDir1 Created....!!n");
// Create The Directory testDir2
Directory.CreateDirectory("C:TestDir1TestDir2");
Console.WriteLine("t Directory: TestDir2 Created....!!n");
// Move The Directory testDir2 As testDir in c:
Directory.Move("C:TestDir1TestDir2", "C:TestDir");
Console.WriteLine("t Directory: TestDir2 Moved....!!n");
// Delete The Directory testDir1
Directory.Delete("C:TestDir1", true);
Console.WriteLine("t Directory: TestDir1 Deleted....!!n");
}
Console.WriteLine("n***************************************************
******n");
Console.ReadKey();
}
}
}
************************************************
DIRECTORY EXAMPLE
************************************************
Directory: TestDir1 Created....!!
Directory: TestDir2 Created....!!
Directory: TestDir2 Moved....!!
Directory: TestDir1 Deleted....!!
************************************************
Output:
Questions….??
Thank You….

More Related Content

What's hot

Inner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVAInner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVATech_MX
 
Java - User Defined classes
Java - User Defined classesJava - User Defined classes
Java - User Defined classesJob Ferrera
 
Java Inner Class
Java Inner ClassJava Inner Class
Java Inner ClassDeeptiJava
 
L5 classes, objects, nested and inner class
L5 classes, objects, nested and inner classL5 classes, objects, nested and inner class
L5 classes, objects, nested and inner classteach4uin
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in JavaRavi_Kant_Sahu
 
15reflection in c#
15reflection  in c#15reflection  in c#
15reflection in c#Sireesh K
 
Open Harvester - Search publications for a researcher from CrossRef, PubMed a...
Open Harvester - Search publications for a researcher from CrossRef, PubMed a...Open Harvester - Search publications for a researcher from CrossRef, PubMed a...
Open Harvester - Search publications for a researcher from CrossRef, PubMed a...Muhammad Javed
 

What's hot (9)

Inner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVAInner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVA
 
Inner class
Inner classInner class
Inner class
 
Java - User Defined classes
Java - User Defined classesJava - User Defined classes
Java - User Defined classes
 
Java Inner Class
Java Inner ClassJava Inner Class
Java Inner Class
 
L5 classes, objects, nested and inner class
L5 classes, objects, nested and inner classL5 classes, objects, nested and inner class
L5 classes, objects, nested and inner class
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in Java
 
15reflection in c#
15reflection  in c#15reflection  in c#
15reflection in c#
 
Windows controls in c
Windows controls in cWindows controls in c
Windows controls in c
 
Open Harvester - Search publications for a researcher from CrossRef, PubMed a...
Open Harvester - Search publications for a researcher from CrossRef, PubMed a...Open Harvester - Search publications for a researcher from CrossRef, PubMed a...
Open Harvester - Search publications for a researcher from CrossRef, PubMed a...
 

Similar to C# Directory class in c#

Asp.net create delete directory folder in c# vb.net
Asp.net   create delete directory folder in c# vb.netAsp.net   create delete directory folder in c# vb.net
Asp.net create delete directory folder in c# vb.netrelekarsushant
 
Recursively Searching Files and DirectoriesSummaryBuild a class .pdf
Recursively Searching Files and DirectoriesSummaryBuild a class .pdfRecursively Searching Files and DirectoriesSummaryBuild a class .pdf
Recursively Searching Files and DirectoriesSummaryBuild a class .pdfmallik3000
 
130614 sebastiano panichella - mining source code descriptions from develo...
130614   sebastiano panichella -  mining source code descriptions from develo...130614   sebastiano panichella -  mining source code descriptions from develo...
130614 sebastiano panichella - mining source code descriptions from develo...Ptidej Team
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Javabackdoor
 
intro unix/linux 07
intro unix/linux 07intro unix/linux 07
intro unix/linux 07duquoi
 
4.file service architecture
4.file service architecture4.file service architecture
4.file service architectureAbDul ThaYyal
 
4.file service architecture (1)
4.file service architecture (1)4.file service architecture (1)
4.file service architecture (1)AbDul ThaYyal
 
classandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.pptclassandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.pptmanomkpsg
 
Slide 1.-datastructure
Slide 1.-datastructureSlide 1.-datastructure
Slide 1.-datastructureMinhaz Leo
 
oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3Atif Khan
 
09 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_1309 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_13Niit Care
 
Chapter 2 Linux File System and net.pptx
Chapter 2 Linux File System and net.pptxChapter 2 Linux File System and net.pptx
Chapter 2 Linux File System and net.pptxalehegn9
 
OOP, Networking, Linux/Unix
OOP, Networking, Linux/UnixOOP, Networking, Linux/Unix
OOP, Networking, Linux/UnixNovita Sari
 

Similar to C# Directory class in c# (20)

Intake 37 11
Intake 37 11Intake 37 11
Intake 37 11
 
Intake 38 10
Intake 38 10Intake 38 10
Intake 38 10
 
Asp.net create delete directory folder in c# vb.net
Asp.net   create delete directory folder in c# vb.netAsp.net   create delete directory folder in c# vb.net
Asp.net create delete directory folder in c# vb.net
 
Chapter 5 Class File
Chapter 5 Class FileChapter 5 Class File
Chapter 5 Class File
 
Recursively Searching Files and DirectoriesSummaryBuild a class .pdf
Recursively Searching Files and DirectoriesSummaryBuild a class .pdfRecursively Searching Files and DirectoriesSummaryBuild a class .pdf
Recursively Searching Files and DirectoriesSummaryBuild a class .pdf
 
130614 sebastiano panichella - mining source code descriptions from develo...
130614   sebastiano panichella -  mining source code descriptions from develo...130614   sebastiano panichella -  mining source code descriptions from develo...
130614 sebastiano panichella - mining source code descriptions from develo...
 
History
HistoryHistory
History
 
C# File IO Operations
C# File IO OperationsC# File IO Operations
C# File IO Operations
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
My History
My HistoryMy History
My History
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
 
intro unix/linux 07
intro unix/linux 07intro unix/linux 07
intro unix/linux 07
 
4.file service architecture
4.file service architecture4.file service architecture
4.file service architecture
 
4.file service architecture (1)
4.file service architecture (1)4.file service architecture (1)
4.file service architecture (1)
 
classandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.pptclassandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.ppt
 
Slide 1.-datastructure
Slide 1.-datastructureSlide 1.-datastructure
Slide 1.-datastructure
 
oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3
 
09 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_1309 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_13
 
Chapter 2 Linux File System and net.pptx
Chapter 2 Linux File System and net.pptxChapter 2 Linux File System and net.pptx
Chapter 2 Linux File System and net.pptx
 
OOP, Networking, Linux/Unix
OOP, Networking, Linux/UnixOOP, Networking, Linux/Unix
OOP, Networking, Linux/Unix
 

More from Prem Kumar Badri

Module 14 properties and indexers
Module 14 properties and indexersModule 14 properties and indexers
Module 14 properties and indexersPrem Kumar Badri
 
Module 12 aggregation, namespaces, and advanced scope
Module 12 aggregation, namespaces, and advanced scopeModule 12 aggregation, namespaces, and advanced scope
Module 12 aggregation, namespaces, and advanced scopePrem Kumar Badri
 
Module 13 operators, delegates, and events
Module 13 operators, delegates, and eventsModule 13 operators, delegates, and events
Module 13 operators, delegates, and eventsPrem Kumar Badri
 
Module 10 : creating and destroying objects
Module 10 : creating and destroying objectsModule 10 : creating and destroying objects
Module 10 : creating and destroying objectsPrem Kumar Badri
 
Module 9 : using reference type variables
Module 9 : using reference type variablesModule 9 : using reference type variables
Module 9 : using reference type variablesPrem Kumar Badri
 
Module 8 : Implementing collections and generics
Module 8 : Implementing collections and genericsModule 8 : Implementing collections and generics
Module 8 : Implementing collections and genericsPrem Kumar Badri
 
Module 6 : Essentials of Object Oriented Programming
Module 6 : Essentials of Object Oriented ProgrammingModule 6 : Essentials of Object Oriented Programming
Module 6 : Essentials of Object Oriented ProgrammingPrem Kumar Badri
 
Module 5 : Statements & Exceptions
Module 5 : Statements & ExceptionsModule 5 : Statements & Exceptions
Module 5 : Statements & ExceptionsPrem Kumar Badri
 
Module 4 : methods & parameters
Module 4 : methods & parametersModule 4 : methods & parameters
Module 4 : methods & parametersPrem Kumar Badri
 
Module 3 : using value type variables
Module 3 : using value type variablesModule 3 : using value type variables
Module 3 : using value type variablesPrem Kumar Badri
 
Module 1 : Overview of the Microsoft .NET Platform
Module 1 : Overview of the Microsoft .NET PlatformModule 1 : Overview of the Microsoft .NET Platform
Module 1 : Overview of the Microsoft .NET PlatformPrem Kumar Badri
 
C# Non generics collection
C# Non generics collectionC# Non generics collection
C# Non generics collectionPrem Kumar Badri
 

More from Prem Kumar Badri (20)

Module 15 attributes
Module 15 attributesModule 15 attributes
Module 15 attributes
 
Module 14 properties and indexers
Module 14 properties and indexersModule 14 properties and indexers
Module 14 properties and indexers
 
Module 12 aggregation, namespaces, and advanced scope
Module 12 aggregation, namespaces, and advanced scopeModule 12 aggregation, namespaces, and advanced scope
Module 12 aggregation, namespaces, and advanced scope
 
Module 13 operators, delegates, and events
Module 13 operators, delegates, and eventsModule 13 operators, delegates, and events
Module 13 operators, delegates, and events
 
Module 11 : Inheritance
Module 11 : InheritanceModule 11 : Inheritance
Module 11 : Inheritance
 
Module 10 : creating and destroying objects
Module 10 : creating and destroying objectsModule 10 : creating and destroying objects
Module 10 : creating and destroying objects
 
Module 9 : using reference type variables
Module 9 : using reference type variablesModule 9 : using reference type variables
Module 9 : using reference type variables
 
Module 8 : Implementing collections and generics
Module 8 : Implementing collections and genericsModule 8 : Implementing collections and generics
Module 8 : Implementing collections and generics
 
Module 7 : Arrays
Module 7 : ArraysModule 7 : Arrays
Module 7 : Arrays
 
Module 6 : Essentials of Object Oriented Programming
Module 6 : Essentials of Object Oriented ProgrammingModule 6 : Essentials of Object Oriented Programming
Module 6 : Essentials of Object Oriented Programming
 
Module 5 : Statements & Exceptions
Module 5 : Statements & ExceptionsModule 5 : Statements & Exceptions
Module 5 : Statements & Exceptions
 
Module 4 : methods & parameters
Module 4 : methods & parametersModule 4 : methods & parameters
Module 4 : methods & parameters
 
Module 3 : using value type variables
Module 3 : using value type variablesModule 3 : using value type variables
Module 3 : using value type variables
 
Module 2: Overview of c#
Module 2:  Overview of c#Module 2:  Overview of c#
Module 2: Overview of c#
 
Module 1 : Overview of the Microsoft .NET Platform
Module 1 : Overview of the Microsoft .NET PlatformModule 1 : Overview of the Microsoft .NET Platform
Module 1 : Overview of the Microsoft .NET Platform
 
C# Non generics collection
C# Non generics collectionC# Non generics collection
C# Non generics collection
 
C# Multi threading
C# Multi threadingC# Multi threading
C# Multi threading
 
C# Method overloading
C# Method overloadingC# Method overloading
C# Method overloading
 
C# Inheritance
C# InheritanceC# Inheritance
C# Inheritance
 
C# Generic collections
C# Generic collectionsC# Generic collections
C# Generic collections
 

Recently uploaded

PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 

Recently uploaded (20)

PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 

C# Directory class in c#

  • 3. Directory Class 1. Deals with Directories and Sub-Directories. 2. Using System.IO 3. Static in Nature. 4. No Instantiation Required. 5. It Cannot be Inherited.
  • 4. Methods: Name Description CreateDirectory(String) Creates all directories and subdirectories in the specified path unless they already exist. CreateDirectory(String, DirectorySecurity) Creates all the directories in the specified path, unless the already exist, applying the specified Windows security. Delete(String) Deletes an empty directory from a specified path. Delete(String, Boolean) Deletes the specified directory and, if indicated, any subdirectories and files in the directory. EnumerateDirectories(String) Returns an enumerable collection of directory names in a specified path.
  • 5. Exists Determines whether the given path refers to an existing directory on disk. Move Moves a file or a directory and its contents to a new location. GetCurrentDirectory Gets the current working directory of the application. SetCurrentDirectory Sets the application's current working directory to the specified directory. GetLastAccessTime Returns the date and time the specified file or directory was last accessed.
  • 6. Remarks:  Efficient to perform One directory-related action.  The static methods of the Directory class perform security checks on all methods.  Make Use of DirectoryInfo instance methods if we want to reuse objects several times.  The security check will not always be necessary.
  • 7. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Threading.Tasks; namespace DirectoryExample { class Program { static void Main(string[] args) { Console.WriteLine("n************************************************** *******n"); Console.WriteLine("tt DIRECTORY EXAMPLE:"); Console.WriteLine("n************************************************** *******n"); if (Directory.Exists("c:testDir1")) { //Shows Message If testdir1 Exists Console.WriteLine("t Directory 'testDir' Exist "); }
  • 8. else { // Create The Directory testDir1 Directory.CreateDirectory("C:TestDir1"); Console.WriteLine("t Directory: TestDir1 Created....!!n"); // Create The Directory testDir2 Directory.CreateDirectory("C:TestDir1TestDir2"); Console.WriteLine("t Directory: TestDir2 Created....!!n"); // Move The Directory testDir2 As testDir in c: Directory.Move("C:TestDir1TestDir2", "C:TestDir"); Console.WriteLine("t Directory: TestDir2 Moved....!!n"); // Delete The Directory testDir1 Directory.Delete("C:TestDir1", true); Console.WriteLine("t Directory: TestDir1 Deleted....!!n"); } Console.WriteLine("n*************************************************** ******n"); Console.ReadKey(); } } }
  • 9. ************************************************ DIRECTORY EXAMPLE ************************************************ Directory: TestDir1 Created....!! Directory: TestDir2 Created....!! Directory: TestDir2 Moved....!! Directory: TestDir1 Deleted....!! ************************************************ Output: