Hey,
Again, there are various ways to do this, and it depends on what you are trying to do, but as a rough guide, this is what you would need to do:
1. Create a FileStream object and either create a new file, or open an existing one.
2. Create a StreamWriter to wrap around the FileStream
3. Use the methods of the StreamWriter to write the information to the file.
4. Once you are done, close the StreamWriter, and then close the FileStream.
It is possible to bypass the need for a FileStream object by simply calling the CreateText method on the File object, which returns a StreamWriter.Code:Dim theFile As FileStream = File.Create("C:\somefile.txt") Dim writer As StreamWriter = New StreamWriter(theFile) writer.WriteLine("Hello") writer.Close() theFile.Close()
Or you can write directly to a file using the WriteAllText method.Code:Dim writer As StreamWriter = File.CreateText("c:\somefile.txt") writer.WriteLine("Hello") writer.Close()
Hope that helps!!Code:File.WriteAllText("c:\somefile.txt", "Hello")
Gary





Reply With Quote