Bài viết này chúng ta sẽ tìm hiểu về phương thức tạo một thư mục trong ngôn ngữ lập trình C#.
Directory.CreateDirectory
Là một phương thức của lớp Directory(class Directory) được sử dụng để tạo một thư mục theo một đường dẫn và tên thư mục(cần tạo) được chỉ định.
Cú pháp - Syntax
public static DirectoryInfo CreateDirectory(
string path
)
string path
)
Ví dụ - Example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace HowToCreatedFolder
{
class Program
{
static void Main(string[] args)
{
string path = @"D:\VNLIVES";
DirectoryInfo di = Directory.CreateDirectory(path);
Console.WriteLine("Directory is created successfully at {0}.", Directory.GetCreationTime(path));
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace HowToCreatedFolder
{
class Program
{
static void Main(string[] args)
{
string path = @"D:\VNLIVES";
DirectoryInfo di = Directory.CreateDirectory(path);
Console.WriteLine("Directory is created successfully at {0}.", Directory.GetCreationTime(path));
Console.ReadLine();
}
}
}
Kết quả - Result
No comments:
Post a Comment