#️⃣ C# To all programmers out there esp. lordrein patulong naman dito please ! :d

Status
Not open for further replies.
oo need mo ng database nun para malagay dun mga ininoput mo sa mga txtbox .. pero try mo yung pinasa kong vid instead na mga char ilagay mo mga txtbox dun :) trial and error lang :)
 
Code:
//sa umpisa to parang import sa java
using System.IO;

        //simula dito
        using (StreamWriter writer =
            new StreamWriter("important.txt"))
        {
            writer.Write("Word ");
            writer.WriteLine("word 2");
            writer.WriteLine("Line");
        }
ts, yung important.txt yung txt file nasa bin/debug directory siya nawriwrite...
lagay niyo po yan sa kung anong button yung dapat pindutin, kuwain niyo lang po value ng mga input tapos lagay niyo sa variable saka niyo iconcatenate (di ko alam syntax ng concatenate sa c#)...
Code:
  string name = textbox1.text;
  int age = textbox2.text;
  writer.Write(name + ', ' age);
 
Code:
using System.IO;

class Program
{
    static void Main()
    {
        using (StreamWriter writer =
            new StreamWriter("important.txt"))
        {
            writer.Write("Word ");
            writer.WriteLine("word 2");
            writer.WriteLine("Line");
        }
    }
}
ts, yung important.txt yung txt file nasa bin/debug directory siya nawriwrite...
thankyou sa idea, ill try..
 
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
          
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string name = textBox1.Text;
            using (StreamWriter writer =
            new StreamWriter("important.txt"))
            {
                writer.Write(name);
            }
        }
    }
}

ito po yung form
name ng textbox is 'textBox1'
button1 naman yung button...
FORM.webp

kumpletuhin niyo na lang po lahat ng data assigning lang po yan, di lang ako sure syntax sa combobox di ako familiar diyan e
 

1. create new project and name it as StreamReadnWrite
2. next insert a button and name it as btnWrite
3. next insert a textbox and name it as txtWriteHere
4. insert this code in the header part "using System.IO;" . please see the sreenshot:


5. double click the button and then insert this code:
Code:
string file_name = "C:/Users/ojt2/Desktop/textfile.txt";

            System.IO.StreamWriter objWriter;
            objWriter = new System.IO.StreamWriter(file_name);

            objWriter.Write(txtWriteHere.Text);
            objWriter.Close();

            MessageBox.Show("File Wrote.");

6. take a look a line "string file_name = " please change it to the path of your desktop
7. now run the program
8. write any text in the textbox and press the button
9. now, take a look at the text file in your desktop (y)
 
Status
Not open for further replies.

About this Thread

  • 38
    Replies
  • 2K
    Views
  • 9
    Participants
Last reply from:
LordRein

Trending Topics

Online now

Members online
1,086
Guests online
966
Total visitors
2,052

Forum statistics

Threads
2,273,948
Posts
28,952,610
Members
1,235,003
Latest member
djjdh
Back
Top