

The path issue is, that with the dos command the tool only works if I have actually an explorer window open in the logfile directory. I was okay to use the dos command, but there is a timing issue and a path issue with it. Only including the VB namespace and this is ruled out, because the tool shall stay small and run only with pure C#. NET has an inbuild command to rename files I cannot find a native C# command. The dos equivalent would be: ren C:\ServerLogs\etc\*.log *.oldlogs NET (no API!) using wildcards and using actually a real "rename" or "name" command, not a move or copy or something like that.ġ) I wish not to move the files, don't suggest to "move" - they are large large files!Ģ) I don't wish to use the Visual Basic namespace for it - I would like to do it with C#. We need something like FileMove, the counterpart to FileCopy, but it only exists, to my knowledge, when using fso.MoveFile which does not allow the use of wildcards.How would I rename a File with pure C#. I know using wildcards is risky, but I'm certain I can identify a unique file. If you know of a way to rename the file, old or current name with wildcards, to new name known in its entirety, it would really speed things up. Fortunately the first line of code, fn, identifies the precise file that needs deleting. At this point it's the best thing I have going. I then go back into the old folder and delete the old file. However, the need for wildcards over rides the time requirement.įn = Dir(myDir & Movie_Actor_Name1 & "*") ' Movie_Actor_Name1 & "*") is old name with wildcardįileCopy myDir & fn, newFolder & Replace(fn, Left(fn, InStr(fn, ".") - 1), Movie_Actor _ Name2) ' Movie_Actor_Name2 is the new, correct name or I should say had 3 problems, 1) I need to use wildcards, 2) some files (more then half) need to be renamed and 3) I would prefer to just move, not copy, because some of these fi les are movies and are large (> 1GB) to copy takes too long.

I don't really need to copy a file, just move it, and in certain cases rename it.

Your code needs to be highlighted! I have been searching for this for days now. I realize the post is over 3 years old but I see you’re still active. Re: File copying & renaming using VBA & WildCards
