Eu tenho esse código estra ido de um link e estou fazendo alguns teste com ele, porem a data de saída esta vindo 18Jan16:09 assim, como faço para formata-la e vim do jeito que esta no arquivo, no arquivo esta assim 01/18/2019 04:09 , quero que saia igual a do arquivo.
protected void Page_Load(object sender, EventArgs e)
{
//FTP Server URL.
string ftp = "ftp://yourserver.com/";
//FTP Folder name. Leave blank if you want to list files from root folder.
string ftpFolder = "Uploads/";
try
{
//Create FTP Request.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftp + ftpFolder);
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
//Enter FTP Server credentials.
request.Credentials = new NetworkCredential("Username", "Password");
request.UsePassive = true;
request.UseBinary = true;
request.EnableSsl = false;
//Fetch the Response and read it using StreamReader.
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
List<string> entries = new List<string>();
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
//Read the Response as String and split using New Line character.
entries = reader.ReadToEnd().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
}
response.Close();
//Create a DataTable.
DataTable dtFiles = new DataTable();
dtFiles.Columns.AddRange(new DataColumn[3] { new DataColumn("Name", typeof(string)),
new DataColumn("Size", typeof(decimal)),
new DataColumn("Date", typeof(string))});
//Loop and add details of each File to the DataTable.
foreach (string entry in entries)
{
string[] splits = entry.Split(new string[] { " ", }, StringSplitOptions.RemoveEmptyEntries);
//Determine whether entry is for File or Directory.
bool isFile = splits[0].Substring(0, 1) != "d";
bool isDirectory = splits[0].Substring(0, 1) == "d";
//If entry is for File, add details to DataTable.
if (isFile)
{
dtFiles.Rows.Add();
dtFiles.Rows[dtFiles.Rows.Count - 1]["Size"] = decimal.Parse(splits[4]) / 1024;
dtFiles.Rows[dtFiles.Rows.Count - 1]["Date"] = string.Join(" ", splits[5], splits[6], splits[7]);
string name = string.Empty;
for (int i = 8; i < splits.Length; i++)
{
name = string.Join(" ", name, splits[i]);
}
dtFiles.Rows[dtFiles.Rows.Count - 1]["Name"] = name.Trim();
}
}
//Bind the GridView.
gvFiles.DataSource = dtFiles;
gvFiles.DataBind();
}
catch (WebException ex)
{
throw new Exception((ex.Response as FtpWebResponse).StatusDescription);
}
}