Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

How to revise incoming file names to give them a prefix name using C# with VS2010?

I am developing an ASP.NET application in C#, using VS2010 and .NET Framework 4.0

I use the following snippet to revised the file extensions of the incoming files to *.ard.out

How would I revise this code to include a prefix filename (variable name of "bankprefix") ?

As you can see, the file name consists of a fixed length of 20 numeric characters followed by a period and then the file extension name.
-----------------------
For example:

string bankprefix = "Bank ABC.";

BEFORE:                                                 AFTER:
20170831509245224004.tiff    ->       Bank ABC.20170831509245224004.ard.out      

-----------------------------------------------------------------------------------------------------------------------------

            DirectoryInfo di = new DirectoryInfo(@MyGlobals.TARGET_DIR_IN);
            FileInfo[] fi = di.GetFiles();
            foreach (FileInfo f in fi)
            {
                File.Move(f.FullName, f.FullName.ToString().Replace(".tiff", ".ard.out"));              
            }
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial