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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:21:39+00:00 2026-05-14T04:21:39+00:00

I am sending mails (in asp.net ,c#), having a template in text file (.txt)

  • 0

I am sending mails (in asp.net ,c#), having a template in text file (.txt) like below

User Name :<User Name>

Address : <Address>.

I used to replace the words within the angle brackets in the text file using the below code

StreamReader sr;
sr = File.OpenText(HttpContext.Current.Server.MapPath(txt));

copy = sr.ReadToEnd();

sr.Close(); //close the reader

copy = copy.Replace(word.ToUpper(),"#" + word.ToUpper()); //remove the word specified UC


//save new copy into existing text file

FileInfo newText = new FileInfo(HttpContext.Current.Server.MapPath(txt));

StreamWriter newCopy = newText.CreateText();
newCopy.WriteLine(copy);
newCopy.Write(newCopy.NewLine);
newCopy.Close();

Now I have a new problem,

the user will be adding new words within an angle, say for eg, they will be adding <Salary>.

In that case i have to read out and find the word <Salary>.

In other words, I have to find all the words, that are located with the angle brackets (<>).

How do I do that?

  • 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-14T04:21:40+00:00Added an answer on May 14, 2026 at 4:21 am

    This is not an answer, but comments can’t do this:

    You should place some of your objects into using blocks. Something like this:

    using(StreamReader sr = File.OpenText(HttpContext.Current.Server.MapPath(txt)))
    {
        copy = sr.ReadToEnd();
    } // reader is closed by the end of the using block
    
    //remove the word specified UC 
    copy = copy.Replace(word.ToUpper(), "#" + word.ToUpper());    
    
    //save new copy into existing text file 
    
    FileInfo newText = new FileInfo(HttpContext.Current.Server.MapPath(txt));
    
    using(var newCopy = newText.CreateText())
    {
        newCopy.WriteLine(copy);
        newCopy.Write(newCopy.NewLine);
    }
    

    The using block ensures that resources are cleaned up even if an exception is thrown.

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

Sidebar

Related Questions

sending mail along with embedded image using asp.net I have already used following but
i am using System.Net.Mail for sending mail in asp.net.. how to delete attachment file
I am sending email from my ASP.net web application. The mails are sending successfully
I'd like to use spring support for sending mails. My project is built with
Possible Duplicates: ASP.NET- Sending an e-mail how to send mail using C#? How can
My site is in asp.net 3.5 and C#. I am sending link to my
I'm writing service which will use for sending emails in my ASP.NET project. I
When I'm creating a user for my web application, an SMTP email (using ASP.NET's
I am creating mail page for sending mails. I need to attach some file
I used to have this code for sending mails: class MailTimerMailer < ActionMailer::Base def

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.