?
Solved

Write to a resource text file in vb

Posted on 2010-04-03
3
Medium Priority
?
345 Views
Last Modified: 2013-11-27
Hi
Hi

I am new to visual studio and want my application to write info to a text file so that it can remember settings.  

I have an "Accounts.txt" in the resources and when the user adds a new account,  the code copies and renames a blank database file but I need to keep track of these filenames and where they are saved so that the user can select the accounts as needed.

Any guidance or suggestions would be appreciated.

This is rather basic I know but I need a bit of a kick start!
0
Comment
Question by:rowanscott
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
cadsjo earned 2000 total points
ID: 29649977
You can write them to a file with the code provided below.

Afterwards you can read each line of the file and split on ";" for example.

Private Sub WriteToFile()
dim strFolder as string = "C:\"
dim strFileName as string = "Textfile.txt"

        Using sw As StreamWriter = File.OpenWrite(Path.Combine(strFolder strFileName))

            sw.WriteLine("Account 1; Path")
            sw.WriteLine("Account 2; Path2")

            sw.Close()

        End Using
End Sub

HTH,
Cadsjo
0
 
LVL 4

Author Comment

by:rowanscott
ID: 29652399
Thanks cadsjo

I think I can follow that OK but how do I get the path to the text file.  It would need to reside in C:\Program Files somewhere I suppose.
0
 
LVL 2

Expert Comment

by:cadsjo
ID: 32640129
You can use Application.ExecutablePath. This returns the path where the application is installed.

You don't have to search yourself.

Cadsjo
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question