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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:25:48+00:00 2026-06-10T00:25:48+00:00

How do I read the text of a resource txt file and put it

  • 0

How do I read the text of a resource txt file and put it into a TextBox in C# .net 4.0 WPF?
I have a TextBox in my form and a TXT file in my resources folder,
how do I put the text from the TXT file (including the line breaks, double spaces, etc) into the TextBox?

Please simplify the code for me because I’m a beginner in C#…
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-10T00:25:49+00:00Added an answer on June 10, 2026 at 12:25 am

    No difference reading file in WinForms or in WPF.
    Simply add to you window TextBox and load file via System.IO.File class.

    Example :

    <Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <TextBox x:Name="tb" Margin="4"/>
        <Button Grid.Row="1" Content="Load file" x:Name="btnLoad" Click="btnLoad_Click" Width="60" HorizontalAlignment="Left" Margin="4"/>
    
    </Grid>
    

    and code behavior :

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    
        private void btnLoad_Click(object sender, RoutedEventArgs e)
        {
            tb.Text = File.ReadAllText(@"*path to file*");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im stucking with Writing to Text File in the Resource, i can read from
I have a resource file in my /res/raw/ folder (/res/raw/textfile.txt) which I am trying
I read a text file to get some info from it and later on
I have to read a text file and based on some logic, make some
I have this text read into an NSString *responce which I am trying to
How do I read an embedded resource (text file) using StreamReader and return it
I have this code: public void readTroops() { File file = new File(resources/objects/troops.txt); StringBuffer
I have added 3 text file resources to an app and am trying to
I have an initialization file (initialize.java) that pulls in data from fileInput.txt using a
I would like to read a text file containing a version number from the

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.