Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete first byte

Status
Not open for further replies.

SgtPeppa

Programmer
Jul 7, 2003
154
DE
Hey all,

i have file and want to delete the first byte of it.
Any approach would be helpful,

Thanks Stephan
 
FileStream fs = new FileStream("c:/something/somewhere/file.txt", FileMode.Open); //i don't know what you file is, it probably isn't this.
StreamReader sr = new StreamReader(fs);

string file = sr.ReadToEnd(); //'file' is your file...
file = file.SubString(1); //...only now it's missing the front

sr.Close();
fs = new FileStream("c:/something/somewhere/file.txt", FileMode.Create); //this will completely destroy your old file. harsh but fair.
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(file); //bingo.
 
Thanks just got my solution working, looks almost like yours :D

Thanks,

Stephan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top