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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:03:05+00:00 2026-05-13T06:03:05+00:00

I have developed an ASP.NET web application in Visual Studio 2008. I have an

  • 0

I have developed an ASP.NET web application in Visual Studio 2008.

I have an HTML document and one text file in the application, but both are not inside my application.

Both are outside, so when I try to run the same application in another system, I get an error because I am missing those files.

I want to include the files inside the application when I deploy it.

Below is the code I use to read and write the files:

//file write test.txt
FileStream file1 = new FileStream("test.txt", FileMode.Create, FileAccess.Write);

// Create a new stream to write to the file
StreamWriter sw1 = new StreamWriter(file1);

// Write a string to the file
sw1.Write(emailId);

// Close StreamWriter
sw1.Close();

// Close file
file1.Close();

// *** Write to file ***

// Specify file, instructions, and privelegdes
FileStream file = new FileStream("test.html", FileMode.Create, FileAccess.Write);

// Create a new stream to write to the file
StreamWriter sw = new StreamWriter(file);

// Write a string to the file
sw.Write(BodyLiteral.Text);

// Close StreamWriter
sw.Close();

// Close file
file.Close();

// *** Read from file ***

// Specify file, instructions, and privelegdes
file = new FileStream("test.txt", FileMode.OpenOrCreate, FileAccess.Read);

// Create a new stream to read from a file
StreamReader sr = new StreamReader(file);

// Read contents of file into a string
string cval = sr.ReadToEnd();
Response.Write(cval);
// Close StreamReader
sr.Close();

// Close file
file.Close();

//html file reading

string text = File.ReadAllText(@"D:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\test.html");

Both of my files are in: D:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\

How can I deploy these two files with application so that the program will work on another system?

  • 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-05-13T06:03:05+00:00Added an answer on May 13, 2026 at 6:03 am

    Your best bet would be Server.MapPath().

    Example:

    Put the files inside folder “file” (you can make a folder in your solution, by right clicking your solution and choose add folder)..
    then right click the folder..choose existing item , and then choose your files..

    To make the path to your files local.. use the follow

    Server.MapPath("~\\files\\test.html");
    

    Your code modified

     FileStream file = new FileStream(  Server.MapPath("~\\files\\test.html"), FileMode.Create, FileAccess.Write);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed an ASP.NET web application in visual studio 2008. I want to
I have an ASP.NET web application developed in Visual Studio 2008, composed of 3
I have developed a web application in asp.net in visual studio 2008. Its working
Scenario : I have an ASP.NET MVC application developed in Visual Studio 2008. There
Im creating a web application in asp.net visual studio 2008.. in my application, i
I'm building an ASP.net application using Visual Studio Web Developer 2010 Express and have
I have a web application developed with ASP.net and C# that is running on
In this very simple ASP.NET application, Visual Web Developer 2008 Express CAN debug the
i have developed a web application with asp.net and c#.net and i use sql
HI, i developed application in Visual Studio... ASP.NET project with master.page. I do it

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.