Talk2Tom11 Posted February 26, 2005 Posted February 26, 2005 hey, my problem is that I am not sure how to add text to a .txt file that already exists. What I want to do it just add the next text on the next line of the .txt file. If anyone knows the code to do this, that would great. Quote
Leaders snarfblam Posted February 26, 2005 Leaders Posted February 26, 2005 Forgive me all you c# users but I do know know how to do this with a filestream off the top of my head, so here it is using the dreaded VB libraries... Dim FileNumber As Integer = FreeFile() FileOpen(FileNumber, ExistingFile, OpenMode.Append) Print(FileNumber, AppendedText) FileClose(FileNumber) ExistingFile would be a string that contains the name of the file you want to append to. AppendedText is... you guessed it, the text to append. Maybe someone more familiar with the FileStream class can show you a "better" way to do it. I've been accessing files the VB way for years and some old habits die hard. Quote [sIGPIC]e[/sIGPIC]
Administrators PlausiblyDamp Posted February 26, 2005 Administrators Posted February 26, 2005 Dim sw As System.IO.StreamWriter = System.IO.File.AppendText("") sw.WriteLine("text to append here") sw.Close() Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.