I have a simple ftp server written in C#. But I am having problems creating folder and file names. If the creation date of the folder or file is greater than 180 days, the folder or file name is created correctly.
Example:
sample img
In this screenshot values like (Tem 07 2023) should not be in the folder name. This values are should be in last write time column.
Here is my code
IEnumerable<string> directories = Directory.EnumerateDirectories(pathname);
foreach (string dir in directories)
{
DateTime editDate = Directory.GetLastWriteTime(dir);
string date = editDate < now.Subtract(TimeSpan.FromDays(180)) ?
editDate.ToString("MMM dd yyyy", CultureInfo.InvariantCulture) :
editDate.ToString("MMM dd HH:mm", CultureInfo.InvariantCulture);
dataWriter.Write("drwxr-xr-x 2 2003 2003 4096 ");
dataWriter.Write(date);
dataWriter.Write(' ');
dataWriter.WriteLine(Path.GetFileName(dir));
dataWriter.Flush();
}
I fix the problem here is the solution, if i write date parameter with this format there is no date in the folder name.
dataWriter.Write($"{date,12:MMM dd HH:mm}");
4