zimmer9
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.a rd.out
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------
DirectoryInfo di = new DirectoryInfo(@MyGlobals.T ARGET_DIR_ IN);
FileInfo[] fi = di.GetFiles();
foreach (FileInfo f in fi)
{
File.Move(f.FullName, f.FullName.ToString().Repl ace(".tiff ", ".ard.out"));
}
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.a
--------------------------
DirectoryInfo di = new DirectoryInfo(@MyGlobals.T
FileInfo[] fi = di.GetFiles();
foreach (FileInfo f in fi)
{
File.Move(f.FullName, f.FullName.ToString().Repl
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.