Once I copied the file, I wanted to rename it, like adding today’s date in the last.
FinalReportFile\\StatusReport TodayDate.xlsx
Thanks In Advance.
Once I copied the file, I wanted to rename it, like adding today’s date in the last.
FinalReportFile\\StatusReport TodayDate.xlsx
Thanks In Advance.
please use for each file in folder and order by the creation date and use break to break after the first only
cheers
I can’t use For each folder, because the folder has other files as well that are not being used.
It has filter as well and you can filter on the file name or extension
Whatever you get from directory.getfiles you have all options here as well with ui to make the life easy
cheers
I want a solution for renaming now.
currentfile.fullname is what you need to give in input
And output how you wan to rename…
You can use this
Currentfile.FullName.Replace(currentfile.Name,"Your newname")
If c# try with square brackets
Cheers
Still getting an error, using the below code for renaming.
CurrentFile. FullName.Replace(CurrentFile.Name,CurrentFile.FullName+DateTime.Today.ToString("dd/MM/yyyy"))
Filenames should not have slashes in it…please remove them…Muy bad…icorrected on top as well
Cheers
Hi, Instead of foreach, can you please try this - Directory.GetFiles(“C:.…”).OrderByDescending(function(r) r).where(function(a) file.GetLastWriteTime(a).Year = Now.Year).First
This can be assigned to a string and you will get the full file path.
Currentfile.Name.Replace not fullname …fullname will take path as welll…name will take only name
Currentfile.FullName.Replace(currentfile.Name,CurrentFile.Name + DateTime.Today.ToString("MMddyyyy"))
Cheers
Hi,
How about the following expression?
System.IO.Path.Combine(CurrentFile.DirectoryName,System.IO.Path.GetFileNameWithoutExtension(CurrentFile.Name)+"_"+DateTime.Now.ToString("MMddyyyy")+CurrentFile.Extension)
Regards,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.