Click here to Skip to main content
15,899,474 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have the Text file XX_TRCSAB_123456.txt I want to Rename the file as TRCSAB_123456.txt

Can you guide me how to achieve this in C sharp
Posted

Try
string oldNameFullPath = "XX_TRCSAB_123456.txt";
var index = oldNameFullPath.indexOf('_');
var newNameFullPath = oldNameFullPath.substring(index, oldNameFullPath.Length - index); 
System.IO.File.Move(oldNameFullPath, newNameFullPath);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900