Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a file with a file name 1471 (ie 1471.txt) this file containing some data
as 456,586,6574,556 etc.How can i append file name to data contains in file and to print in output

required o/p:
1471,456,586,6574,556

hlp me & rply me plzz
Posted
Updated 19-Oct-11 19:44pm
v2

1 solution

Use the following code :
C#
string filename = Path.GetFileNameWithoutExtension(filepath);
StringBuilder sb = new StringBuilder();
sb.Append(filename + ",");
sb.Append(File.ReadAllText(fileapth));
File.WriteAlltext(filepath, sb.ToString());
 
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