none
Writing to AppData roaming folder RRS feed

  • Question

  • Hi,

    I have an Outlook 2010/2013 addin and need to store some generated text files that can be accessed in the roaming profile of the user.  Currently I am using:

    My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData & "\[Addin_name]t\"

    as the location, however I have found that this stores it in:

    C:\Users\[Username]\AppData\Roaming\Microsoft Corporation\Microsoft Outlook\14.0.7151.5000\[Addin_name]\

    The problem is that when Outlook updates itself automatically, the version number changes and it creates a new folder in Microsoft Outlook where it will save my text files, e.g.

    C:\Users\[Username]\AppData\Roaming\Microsoft Corporation\Microsoft Outlook\14.0.7151.6000\[Addin_name]\

    How do I create a folder within AppData specific to my product/addin and therefore won't ever change?

    Thanks,

    Tom

    Friday, June 26, 2015 9:24 AM

Answers

  • Hello Tom,

    It is not clear what code you use for getting a roaming folder for the user, but you may use the following line of code to get the Roaming folder:

    string path = System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
    You can simply create a subfolder for your data and don't depend on the Outlook folders.

    Friday, June 26, 2015 11:19 AM
  • Tom,

    Just try to run the code I listed above and you will see something like that:

    "C:\Users\Eugene\AppData\Roaming"

    where Eugene is the user's name.

    Friday, June 26, 2015 12:22 PM

All replies

  • Hello Tom,

    It is not clear what code you use for getting a roaming folder for the user, but you may use the following line of code to get the Roaming folder:

    string path = System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
    You can simply create a subfolder for your data and don't depend on the Outlook folders.

    Friday, June 26, 2015 11:19 AM
  • Tom,

    MSDN says :

    The My.Computer.FileSystem.SpecialDirectories Object contains paths to commonly referenced directories.

    If the path does not exist, it is created with the following format: BasePath\CompanyName\ProductName\Version

    Hope this helps.

    Friday, June 26, 2015 11:24 AM
  • Hi all,

    Thanks for your responses, I can use Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) and that works great for then using my own path after that to create a folder for my addin.

    My question is, how will this work in an environment where many users use the same computer and each login and have their roaming profiles.  Will this be able to detect the correct user and use their specific roaming profile?

    Cheers,

    Tom


    • Edited by moatak787 Friday, June 26, 2015 11:35 AM
    Friday, June 26, 2015 11:34 AM
  • Tom,

    Just try to run the code I listed above and you will see something like that:

    "C:\Users\Eugene\AppData\Roaming"

    where Eugene is the user's name.

    Friday, June 26, 2015 12:22 PM