Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8195675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:13:02+00:00 2026-06-07T05:13:02+00:00

I have a HTML file in C:\Users\myusername\AppData\Roaming\myapp\file.html . I am accessing the file through

  • 0

I have a HTML file in C:\Users\myusername\AppData\Roaming\myapp\file.html. I am accessing the file through a web Browser in my C# application to preview it from within the app.
However, when the app is put onto another computer, the address in webBrowser1 is still specific to my username, and therefore other people cannot access the preview.

Is there a way to get to the file as a URL in my web Browser without having the hard coded username in the URL?

What I have tried:

  1. C:\Users\%USERNAME%\AppData\Roaming\myapp\file.html
  2. C:\Users\AppData\Roaming\myapp\file.html

Thanks!

Here is the code I used after I was helped:

string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string address = Path.Combine(folderPath + @"\myapp\file.html");
webBrowser1.Navigate(address);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:13:03+00:00Added an answer on June 7, 2026 at 5:13 am

    If you want to get the name of the current logged in user you have to read Environment.UserName property.

    Moreover if you need to access the AppData directory for the roaming user you can get the folder path without hard-coding anything (do not forget that users directory isn’t always c:\users on every Windows version and path for AppData may vary too):

    string folderPath = Environment.GetFolderPath(
        Environment.SpecialFolder.ApplicationData);
    

    In you case simply append the file name:

    string url = Path.Combine(folderPath, "file.htm");
    

    Notes
    If, for any reason, you need to use environment variables then you have first to expand them:

    string path = Environment.ExpandEnvironmentVariables(@"C:\Users\%USERNAME%\");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From the page file://localhost/Users/pistacchio/dev/epress/catflow/test_html/index.html I have the following (coffeescript) code trying to access an
I have a web application that lets users upload entire .html files to my
I have a HTML file, which generates a web page. Users can enter some
I have a html page that allows users to submit a file. Below is
I have an HTML file and i would like to parse through it using
I have following html file (1.html) and once I open it in my browser
I have a html file and I want to open it from my mfc
How can I load a HTML from the local file system? I have seen
I have an index.html.erb file with the following: <%= render @users %> This renders
I have a site, from which you can download an HTML file. This HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.