Today, we discussed Date Format Directory in C#.Net
Code:
public static void CreateDirectory(string DesignationPath) { if (!Directory.Exists(DesignationPath)) { Directory.CreateDirectory(DesignationPath); } } public static string currentYear() { string Year = string.Empty; DateTime dt = DateTime.Now; string format = "yyyy"; Year = dt.ToString(format); return Year; } public static string currentMonth() { string Month = string.Empty; DateTime dt = DateTime.Now; string format = "MM"; Month = dt.ToString(format); return Month; } public static string currentDate() { string day = string.Empty; DateTime dt = DateTime.Now; string format = "dd"; day = dt.ToString(format); return day; }
Code:
public static void CreateDirectory(string DesignationPath) { if (!Directory.Exists(DesignationPath)) { Directory.CreateDirectory(DesignationPath); } } public static string currentYear() { string Year = string.Empty; DateTime dt = DateTime.Now; string format = "yyyy"; Year = dt.ToString(format); return Year; } public static string currentMonth() { string Month = string.Empty; DateTime dt = DateTime.Now; string format = "MM"; Month = dt.ToString(format); return Month; } public static string currentDate() { string day = string.Empty; DateTime dt = DateTime.Now; string format = "dd"; day = dt.ToString(format); return day; }