Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
VB.NET
VB.NET General Discussion
Writing lines in text file
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="jmcilhinney, post: 186033, member: 641"] This is a simple matter of scope. You create a [ICODE]StreamWriter[/ICODE] object and assign it to the local variable [ICODE]aFile[/ICODE]. That means that you can only access that object where you can access that variable. If you want to access the object outside that method then you need to assign it to a variable that is accessible outside that method. That said, you probably shouldn't do that anyway. It's generally not going to be appropriate to open a file and then keep it open for long periods of time that you're not using it. You should generally open the file, use it as required and then close it, opening it again later if you need to use it again. You can just call the [ICODE]File.AppendAllText[/ICODE] to write text to the end of a file wherever you like, without need of a [ICODE]StreamWriter[/ICODE] object or variable of your own. [/QUOTE]
Insert quotes…
Verification
Post reply
VB.NET
VB.NET General Discussion
Writing lines in text file
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom