

InterviewSolution
Saved Bookmarks
1. |
Solve : vb express append to file? |
Answer» in VISUAL basic express how would i append a string called list to a text file call recipes.txt in the current directoryyou should always check MSDN first (or google). Use the append mode when opening the file for writingno the problem is i cant write to the file at all i should have been more specificQuote from: mat123 on December 24, 2010, 06:33:30 PM no the problem is i cant write to the file at all i should have been more specificand why are you not being specific about why you can't write to file , when you know you should? What error messages? did you open you file properly? Without your code, there's no way to know what went wrong isn't it?Code: [Select] Dim path As String = My.Computer.FileSystem.CurrentDirectory() Debug.Write(path) Dim sw As System.IO.StreamWriter Dim Loc = path + "recipes.txt" sw = My.Computer.FileSystem.OpenTextFileWriter(Loc, True code] then a sw.writeline(list)tips: -Stay AWAY from the My Namespace stuff. IMO it's a pretty big hack; also, it doesn't exist in any other .NET language, so in a way it's SOMEWHAT "non-standard". - Use Path.Combine() to combine paths. Example: Code: [Select] Dim destfile as String = Path.Combine(Environment.CurrentDirectory,"recipes.txt") Dim fstream As FileStream = new FileStream(destfile,FileMode.Append) dim twriter as StreamWriter = new StreamWriter(fstream) dim list as String="list" twriter.WriteLine(list) twriter.Close() I haven't a clue what your list variable was SUPPOSED to be. i still does not write to the file there is no error thoughWhy don't you check out MSDN (which i have already told you in my first post ) and see what they say. EXECUTE the example code provided, and see if you can write to file.i finally got it work but how do it get it to be a exe the publish option makes a setup file i just want a stand alone exeuse Build->Build Solution. (Assuming the express versions are similar in menu structure to Professional) thank you both of you for your help. |
|