Click here to Skip to main content
15,889,216 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: VB Photo Screensaver Pin
Nate Schoonover29-Dec-13 5:37
Nate Schoonover29-Dec-13 5:37 
GeneralRe: VB Photo Screensaver Pin
Eddy Vluggen29-Dec-13 17:15
professionalEddy Vluggen29-Dec-13 17:15 
GeneralRe: VB Photo Screensaver Pin
Nate Schoonover31-Dec-13 9:00
Nate Schoonover31-Dec-13 9:00 
GeneralRe: VB Photo Screensaver Pin
Eddy Vluggen2-Jan-14 9:18
professionalEddy Vluggen2-Jan-14 9:18 
GeneralRe: VB Photo Screensaver Pin
Nate Schoonover2-Jan-14 11:37
Nate Schoonover2-Jan-14 11:37 
GeneralRe: VB Photo Screensaver Pin
Eddy Vluggen4-Jan-14 3:41
professionalEddy Vluggen4-Jan-14 3:41 
GeneralRe: VB Photo Screensaver Pin
Nate Schoonover4-Jan-14 18:17
Nate Schoonover4-Jan-14 18:17 
GeneralRe: VB Photo Screensaver Pin
Eddy Vluggen5-Jan-14 1:25
professionalEddy Vluggen5-Jan-14 1:25 
Nate Schoonover wrote:
I store my pictures under C:\Users\Public\Pictures\... and I can't navigate to this folder.
It should be accessible using the Explorer; if it's not, it won't be accessible from code either. It should be a writeable location under a default-installation. You can get the location with the snippet below;
VB
Dim thePath As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures)
Nate Schoonover wrote:
Is there a better way to store basic application settings?
The advantage of the "My Settings"-editor in Visual Studio is that it's clean, well-documented and has a nice UI. The advantage of writing your own is having a bit more control. I've included a small example that shows how to serialize/deserialize a POCO using a BinaryFormatter. There are more formatters available, one of them being for XML.
VB
Imports System.Runtime.Serialization.Formatters.Binary

Module Module1

    <Serializable()> _
    Public Class MySettings
        Public Property SomePath As String
        Public Property SomeInt As Integer
    End Class

    Sub Main()
        ' get location of public pictures
        Dim thePath As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures)

        ' Generate some settings
        Dim CurrentSettings As New MySettings
        CurrentSettings.SomePath = thePath
        CurrentSettings.SomeInt = 2

        ' Save settings
        Dim formatter As New BinaryFormatter
        Using s As New IO.FileStream(".\settings.bin", IO.FileMode.Create)
            formatter.Serialize(s, CurrentSettings)
        End Using

        ' Load settings again
        Dim PrevSavedSetting As MySettings
        Using s As New IO.FileStream(".\settings.bin", IO.FileMode.Open)
            PrevSavedSetting = formatter.Deserialize(s)
        End Using

        ' Write the settings we just read to screen
        Console.WriteLine(PrevSavedSetting.SomePath)
        Console.WriteLine(PrevSavedSetting.SomeInt)
        Console.ReadKey()
    End Sub

End Module
This will save (and read) the contents of the MySettings object in a file called "settings.bin" in the current working-directory of the application.

Happy coding Thumbs Up | :thumbsup:
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

QuestionDataGridView populates only first row Pin
Sonhospa27-Dec-13 9:16
Sonhospa27-Dec-13 9:16 
AnswerRe: DataGridView populates only first row Pin
Eddy Vluggen29-Dec-13 2:51
professionalEddy Vluggen29-Dec-13 2:51 
AnswerRe: DataGridView populates only first row Pin
Sonhospa29-Dec-13 7:08
Sonhospa29-Dec-13 7:08 
GeneralRe: DataGridView populates only first row Pin
Eddy Vluggen29-Dec-13 17:12
professionalEddy Vluggen29-Dec-13 17:12 
QuestionLINQ Pin
tsunamigang23-Dec-13 18:04
tsunamigang23-Dec-13 18:04 
AnswerRe: LINQ Pin
thatraja23-Dec-13 20:09
professionalthatraja23-Dec-13 20:09 
GeneralRe: LINQ Pin
tsunamigang23-Dec-13 22:08
tsunamigang23-Dec-13 22:08 
QuestionProgressbar value not accurate? Pin
Sonhospa21-Dec-13 0:50
Sonhospa21-Dec-13 0:50 
AnswerRe: Progressbar value not accurate? Pin
Dave Kreskowiak21-Dec-13 4:50
mveDave Kreskowiak21-Dec-13 4:50 
NewsRe: Progressbar value not accurate? Pin
Sonhospa21-Dec-13 9:04
Sonhospa21-Dec-13 9:04 
GeneralRe: Progressbar value not accurate? Pin
Dave Kreskowiak21-Dec-13 11:34
mveDave Kreskowiak21-Dec-13 11:34 
QuestionVerification Failure (DigitalPersona 4000B) Pin
Member 1048039921-Dec-13 0:35
Member 1048039921-Dec-13 0:35 
AnswerRe: Verification Failure (DigitalPersona 4000B) Pin
Dave Kreskowiak21-Dec-13 4:46
mveDave Kreskowiak21-Dec-13 4:46 
QuestionException Pin
tsunamigang19-Dec-13 20:10
tsunamigang19-Dec-13 20:10 
AnswerRe: Exception Pin
Richard MacCutchan19-Dec-13 21:57
mveRichard MacCutchan19-Dec-13 21:57 
QuestionAnyone else with VB 2010 forms suddenly slow? Pin
BradITM19-Dec-13 11:43
BradITM19-Dec-13 11:43 
AnswerRe: Anyone else with VB 2010 forms suddenly slow? Pin
Dave Kreskowiak19-Dec-13 12:46
mveDave Kreskowiak19-Dec-13 12:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.