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 9154593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:27:09+00:00 2026-06-17T12:27:09+00:00

After much searching and looking extensively, I have a question that is undoubtedly dumb

  • 0

After much searching and looking extensively, I have a question that is undoubtedly dumb but I’m just missing something easy. I just published my first website and obviously had to make a few changes. I’m using a writer class, before it was just writing to a path on my computer, but that’s obviously not an option now, what I’m trying is this:

using (StreamWriter writer = new StreamWriter(@"~\Files\test.txt"))

I just want this to write this to the Files folder in my project. What’s the syntax? I’m also using dotnetzip and having the same issue trying a different syntax:

zip.AddFile("Files/test.txt");

What’s the way to do this? Thanks!

  • 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-17T12:27:10+00:00Added an answer on June 17, 2026 at 12:27 pm

    For a Windows (desktop) application, do:

    Path.Combine(Application.StartupPath, "Files", "test.txt")
    

    The application path is accessible in Application.StartupPath, and you can use Path.Combine to combine parts of a path together.

    For ASP.net, you need Server.MapPath instead of Application.StartupPath:

    Path.Combine(Server.MapPath("~", "Files", "test.txt")
    

    Of course since this is all hardcoded, you should also be able to simply do

    Server.MapPath("~/Files/test.txt")
    

    Depending on your needs, you may need to use . instead of ~. See also Server.MapPath("."), Server.MapPath("~"), Server.MapPath(@"\"), Server.MapPath("/"). What is the difference?.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After much searching, I have not found a satisfactory method that is easy to
After Much searching I have decided to ask my first stack overflow question: View
This might be a very simple question but after much searching on different forums
After much searching and googling I am coming back to the well. I have
After much searching and trials, I am stuck... I have two classes, one is
After much searching the answer seems to be no, but I thought I'd ask
It appears after much searching that there seems to be a common problem when
After much searching I've found lots of relevant questions to normal classes, but none
After much searching, it looks like I have to assign RegisterComponentsProc and RegisterPropertyEditorProc ,
After much google searching and looking through other posts here i still can't work

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.