Contenido del Curso
Introduction to .NET with C#
Introduction to .NET with C#
2. Asynchronous Programming and Introduction to Web Services
3. Introduction to Databases with .NET
Writing Files
Recap
- We can use the
StreamWriter
object for writing files; - If the file at the specified path does not exist, the
StreamWriter
object creates it; - If the file at the specified object already exists, the
StreamWriter
object by default overwrites it - which means that the previous content will be deleted. We will learn how to prevent that in the upcoming section; StreamWriter
has aWriteLine
method for writing a line of text into a file. This method automatically moves the cursor to the next line after writing is done. In other words, it automatically appends a "\n" character after the text we write into the file;- Similar to
WriteLine
, there is aWrite
method, however, it doesn't move the cursor to the next line after writing text into a file; - Just like
StreamReader
, we also need to close theStreamWriter
object either by using theClose()
method or by utilizing theusing
statement to automatically close it after use.
¿Todo estuvo claro?