Hi,
Is there a way where I can update the date and time modified of files in the File Manager based on a timezone that will be specified in the code?
We have this requirement where we can change the timezone setting of the website and this affects all dates and times in the website which includes the date modified field of the files in File Manager.
Thanks!
Homecontroller.cs
public object getFiles(FileManagerDirectoryContent args) {
FileResponse readResponse = new FileResponse();
try
{
var value = this.operation.GetFiles(args.Path, args.ShowHiddenItems);
DirectoryContent cwd = new DirectoryContent();
readResponse.CWD = JsonConvert.DeserializeObject<DirectoryContent>(JsonConvert.SerializeObject(value.CWD));
readResponse.Files = JsonConvert.DeserializeObject<IEnumerable<DirectoryContent>>(JsonConvert.SerializeObject(value.Files));
//Add the additional parameter for each files in filemanager component.
foreach (DirectoryContent file in readResponse.Files)
{
// Converting Date and Time.
file.DateModified = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
}
readResponse.Details = value.Details;
readResponse.Error = value.Error;
return readResponse;
}
catch
{
ErrorDetails er = new ErrorDetails();
}
return this.operation.ToCamelCase(this.operation.GetFiles(args.Path, args.ShowHiddenItems));
}
[Route("FileOperations")]
public object FileOperations([FromBody] FileManagerDirectoryContent args)
{
switch (args.Action)
{
case "read":
// reads the file(s) or folder(s) from the given path.
return this.getFiles(args); }
------------------------------------------------------------------------- index.razor <SfFileManager TValue="FileManagerDirectoryContent" View="ViewType.Details">
<FileManagerDetailsViewSettings>
<FileManagerColumns>
<FileManagerColumn Field="DateModified" HeaderText="Date Modified">
</FileManagerColumn>
</FileManagerColumns>
</FileManagerDetailsViewSettings>
</SfFileManager> |