Search code examples
c#pathdirectoryappdata

Directory Configuration in C#


I would like to read from a htm file, that is located to the following directory:

C:\Users\**NAME**\AppData\Roaming\Microsoft\Signatures

How can I change the path, so that I can use it from another computer, where the user name is not equal to the one above?

DirectoryInfo directoryInfo = new DirectoryInfo(Environment.SpecialFolder.ApplicationData + @"Roaming\Microsoft\Signatures");

Solution

  • Environment.SpecialFolder is an enumeration, you need to call GetFolderPath to get the actual path. Also ApplicationData includes the "Roaming" part, so you don't need that

    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Signatures"