Hello,
I'm using this code to make my app. run at startup if a CheckBox is checked
However, when the app. starts it loads some text to a ListBox. But, when the app. run at startup it creates a directory in:Code:Private Sub CheckBox5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox5.CheckedChanged If CheckBox5.Checked = True Then CheckBox6.Checked = False CheckBox6.Enabled = False Dim key As Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True) key.SetValue("To-Do List", Application.ExecutablePath) My.Settings.DefaultCheck5 = True ElseIf CheckBox5.Checked = False Then CheckBox6.Enabled = True Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).DeleteValue("To-Do List", False) My.Settings.DefaultCheck5 = False End If End Sub
C:\Documents and Settings\%userprofile%\%app. folder%
and its supposed to load the text from
Directory.GetCurrentDirectory.ToString & "\My Program\textfile.txt"
This is my FormLoad code:
Code:Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ListBox1.Items.Clear() 'Sets the CurrentUser to an empty string My.Settings.CurrentUser = "" 'Gets the curent directory of the application My.Settings.CurrentDirectory = Directory.GetCurrentDirectory.ToString 'Checks to see if it's the first run of the program If My.Settings.FirstRun = True Then UserINFO.ShowDialog() My.Settings.FirstRun = False ElseIf My.Settings.FirstRun = False Then 'Checks if the Settings folder exists If Directory.Exists(My.Settings.CurrentDirectory & "\Settings\Usernames") = False Then Directory.CreateDirectory(My.Settings.CurrentDirectory & "\Settings\Usernames") End If End If 'Handles the ToolTip delay Me.ToolTip1.ReshowDelay = 10 Me.ToolTip1.InitialDelay = 1000 'Handles fade-in effects If My.Settings.DisableFadeIn = True Then Timer1.Enabled = False Me.Opacity = 100 ManageUsers.Timer1.Enabled = False ManageUsers.Opacity = 100 ElseIf My.Settings.DisableFadeIn = False Then Timer1.Enabled = True ManageUsers.Timer1.Enabled = True End If 'Settings from Customize form With Me .ListBox1.ForeColor = My.Settings.DefaultColor .FormBorderStyle = My.Settings.DefaultCustomBorder .Button1.Visible = My.Settings.DefaultButton1 .Button2.Visible = My.Settings.DefaultButton2 .Button3.Visible = My.Settings.DefaultButton3 .Size = My.Settings.DefaultSize .ShowInTaskbar = My.Settings.ShowInTaskbar End With With Customize .CheckBox1.Checked = My.Settings.DefaultCheck1 .CheckBox2.Checked = My.Settings.DefaultCheck2 .CheckBox3.Checked = My.Settings.DefaultCheck3 .CheckBox4.Checked = My.Settings.DefaultCheck4 .CheckBox5.Checked = My.Settings.DefaultCheck5 .CheckBox6.Checked = My.Settings.DefaultCheck6 .CheckBox7.Checked = My.Settings.DefaultCheck7 End With PrintSettings.Enabled = My.Settings.DefaultPrinterSettings 'Settings end here ManageUsers.ShowDialog() TextBox1.Focus() End Sub





Reply With Quote