Results 1 to 4 of 4

Thread: [RESOLVED] Accessing public documents folder in code

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Location
    Australia
    Posts
    1,162

    Resolved [RESOLVED] Accessing public documents folder in code

    Hello

    I have this code working to place a file in the my documents folder in any version (I hope) of the o/s

    Public Class Form1 'test file access

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Try
    Dim filePath As String
    filePath = System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "test.txt")

    My.Computer.FileSystem.WriteAllText(filePath, "some text", False)
    Catch fileException As Exception
    Throw fileException
    End Try
    End Sub
    End Class


    I would like to access the *public* documents file via the SpecialDirectories statement and am so far failing to do it.

    In VB6 I could access the public documents file by

    GetSpecialFolder(CSIDL_COMMON_DOCUMENTS)

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Accessing public documents folder in code

    Try the Environment.GetFolderPath method. You can specify CommonDocuments as the folder whose path to get.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Location
    Australia
    Posts
    1,162

    Re: Accessing public documents folder in code

    ... and although we mutually ignored each other, that is just what I did and was about to mark the thread resolved. BTW, your explanation still far too terse for my tiny mind, but I found it anyway and have

    'aPath is my allocated string variable
    aPath = Environment.GetFolderPath(Environment.SpecialFol der.CommonDocuments)

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Accessing public documents folder in code

    I guess some impediments simply cannot be overcome.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width