dcsimg
Results 1 to 5 of 5

Thread: [RESOLVED] Folder structure

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    27

    Resolved [RESOLVED] Folder structure

    1) I used the following to setup a Function: Return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FDS", "FDSPro", filename)

    2) This causes the following error: System.IO.DirectoryNotFoundException: 'Could not find a part of the path 'C:\Users\Admin\AppData\Local\FDS\FDSPro\FileStartup.txt'.'

    FileStartup is the first file to be read.
    3) If I use the following instead: Return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), filename)
    Everything works OK except that all of the files are placed in the: User\Admin\AppData\Local folder.
    I would like the additional folders added so that it resembles other installed Apps. More professional.

    Can anybody help with this please
    NB: My App ensures that ALL of the files needed are created using Try/Catch/EndTry...thanks all, Paul

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,431

    Re: Folder structure

    The directories aren't there unless you create them.
    A more professional app would create the directories you need if they don't exist...

    Code:
    If Not IO.Directory.Exists(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FDS")) Then
        IO.Directory.CreateDirectory(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FDS"))
        IO.Directory.CreateDirectory(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FDS\FDSPro"))
        'write FileStartup.txt here
    End If

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    27

    Re: Folder structure

    Quote Originally Posted by .paul. View Post
    The directories aren't there unless you create them.
    A more professional app would create the directories you need if they don't exist...

    Code:
    If Not IO.Directory.Exists(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FDS")) Then
        IO.Directory.CreateDirectory(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FDS"))
        IO.Directory.CreateDirectory(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FDS\FDSPro"))
        'write FileStartup.txt here
    End If
    Would I then use: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FDS\FDSPro", filename) in order for my App to know where Windows has put them? I only learned about this yesterday...I am a newbie trying to learn so I would appreciate all the help you can give me, thanks. Paul

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    27

    Re: Folder structure

    OK, figured it out...thanks

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,431

    Re: [RESOLVED] Folder structure

    Simply, Yes. Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) returns the variable part. You yourself know what directory structure you've created and what you've put in those folders

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width