Click here to Skip to main content
15,888,239 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am implementing an utility,in that i have to read data from a file ,and then i have to pass the particular data to particular text boxes , in this am using open dialogue box,
am able to read the complete data but for selecting particular data and importing to text boxes i am not able do ,so any one plz help me to resolve this problem.

What I have tried:

C#
public partial class Form1 : Form
    {
        private string productName = string.Empty;
        private string FrmvareVs = string.Empty;
        private string RlsDate = string.Empty;
        private string HexFile = string.Empty;
        private string cmssnWizard = string.Empty;
        private string InstalationVer = string.Empty;
        private string LbdDependent = string.Empty;
        private string HelpDependent = string.Empty;

        string strProductPath = string.Empty;
        private string filePath = string.Empty;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Filter = "Iss Files (.iss)|*.iss|All Files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = openFileDialog1.FileName;
                // Open the selected file to read.
                System.IO.Stream fileStream = openFileDialog1.OpenFile();
                string readContents;
                using (System.IO.StreamReader reader = new System.IO.StreamReader(fileStream))
                {

                  
                    readContents = reader.ReadToEnd();
                    //textBox4.Text = readContents;


                    fileStream.Close();
                }
Posted
Updated 8-Jun-16 20:13pm
v2
Comments
Garth J Lancaster 9-Jun-16 1:35am    
I think you need to use the 'Improve question' widget and show as an example of the file/data.

The solution could be as simple as substrings, or regular expressions, or hopefully not, a full parser - but we cant see your screen/the file so we cant advise how to extract the data from it
Member 12528561 9-Jun-16 2:37am    
i have a windows form,in that i have 8 text boxes ,and i am using openFileDialog , so from the file i have read the data,and then that i want export to related text box,
Ex:in file there is "Product type " then thats value is something like 123g65
so that i want to export only product value only to my text box.
This is my task,so can you help me .
BillWoodruff 9-Jun-16 2:05am    
As Garth says, you need to describe what you either know is, or think is, the file structure. Did you create the file; if not, do you have documentation of its internal structure? If you don't know the internal structure, and don't have documentation for it, then open the file in a Text editor and study its structure.

For example,
C#
myTextBox.Text = System.IO.File.ReadAllText(myFileName);


—SA
 
Share this answer
 
Comments
koolprasad2003 9-Jun-16 2:09am    
+5simple and short
Sergey Alexandrovich Kryukov 9-Jun-16 2:12am    
Thank you, Prasad.
—SA
Reading the entire file into a single textbox object using a StreamReader ReadToEnd() method
C#
using (StreamReader sr = File.OpenText(fileName))
{
         Textbox.Text = sr.ReadToEnd();
        //you then have to process the string
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900