|By: Paul S. Cilwa||Viewed: 11/19/2019
|Topics/Keywords: #Computers #Programming #Organica #VB.NET||Page Views: 515|
|How to determine if Organica has ever before been run on this computer.|
What happens the very first time a user puts his foot in the water, so to speak, and runs Organica? We've already made an effort to "position" the running program so that it is "in" the user's home directory. But Organica needs to be able to create a directory for itself, with at least an INI file with default preferences.
Previously we put code in Frame to locate the user directory. But that's not enough for real life. We're going to append two procedures to the ThisUser class.
The first does the work of creating an Organica.ini file in any specified location.
ThisUser.vb (append)Private Function CreateOrganicaHome(ByVal HomePath As String) As ProfileDocument IO.Directory.CreateDirectory(HomePath) HomePath = My.Computer.FileSystem.CombinePath(HomePath, "Organica.ini") Dim IniFile As New ProfileDocument(HomePath) With IniFile .WriteData("IconPath", "[UserPhoto]") .WriteData("DisplayName", "[UserDisplayName]") .UserSince = Now.Date.ToString("d") .WriteLink("Music", KnownFolders.MyMusic().FullName, "Icons\Music.png") .WriteLink("Pictures", KnownFolders.MyPictures().FullName, "Icons\Photos.png") .WriteLink("Videos", KnownFolders.MyVideos().FullName, "Icons\Videos.png") .WriteLink("Documents", KnownFolders.MyVideos().FullName, "Icons\Documents.png") End With Return IniFile End Function
Please note that this code is going to create three links to Music, Pictures, Videos and Documents. These links include icons for those Folders. Here are the ones I chose to use, for your convenience.
Then we're ready to enhance the Directory property of ThisUser. This property has the task of determining where the initialization should take place, where the .INI file should go, and then invoke the above routine to do the work.