Today's upload is a simple class I've made to help all of out there who are constantly needing to make saves to the app data folders (aka, where every good windows program saves any user data that is not registry filed).
The class isn't very complex and, if you're a beginner looking to see some simple class stuff and simple file and folder checks, enjoying breaking it down. Otherwise, just add this class to any project and enjoy free and easy file saving!
The class does 1 of 2 things when called.
It either
A: creates "Path" (not a file or folder) for the current user that is located in the Program Data folder area
or
B: creates a Public "Path" at the Program Data Location
This class helps to ensure you are quickly and easily saving to the same folder "area" as everyone else who writes anything decent for windows.
It also includes 2 very basic functions "create" & "delete" which, of course, create or delete whatever your current path is (the path created when you called the class).
Example 1 Code:
Dim bob As New SaveFile("SomeFolder(usuallyAppName)", "SomeFile.txt")
' Optional para let's u choose whether it includes the current username or if it goes in a public folder
' then reuse is ez, like ...
SomeReadWriteClass.Save(bob.file.path)
to see more examples of how it will pull,
create a new form proj
add this class
add a richtextbox
then add the following code to the form's load event
Example 2 Code:
Dim bob As New SaveFile("", "SomeFile.txt")
With bob
rtxTest.AppendText(.adpUserPath)
rtxTest.AppendText(Environment.NewLine)
rtxTest.AppendText(Environment.NewLine)
rtxTest.AppendText(.Folder.Name)
rtxTest.AppendText(Environment.NewLine)
rtxTest.AppendText(.Folder.Path)
rtxTest.AppendText(Environment.NewLine)
rtxTest.AppendText(.Folder.Exist)
rtxTest.AppendText(Environment.NewLine)
rtxTest.AppendText(.File.Name)
rtxTest.AppendText(Environment.NewLine)
rtxTest.AppendText(.File.Path)
rtxTest.AppendText(Environment.NewLine)
rtxTest.AppendText(.File.Exist)
rtxTest.AppendText(Environment.NewLine)
.Folder.Name = .Folder.Name & "\NewSubFolder"
rtxTest.AppendText(.Folder.Path)
rtxTest.AppendText(Environment.NewLine)
bob = New SaveFile(.Folder.Name.Replace("\NewSubFolder", "") & "\NewSubFolder", "Bob.exe")
The attached zip includes both the simple vb class and a dll you can use to just reference in if preferred. Note: you do not need both, as they are both the same thing.