Split Code to Multiple Files in c++ and c# with GUI using WindowsForm 56

Опубликовано: 26 Июль 2026
на канале: Arif Mahmood
765
2

Shows how to #divide/#split #code into #multiple #files in a #GUI #project using #windows #form #application in c plus plus and c sharp.


C# Code:


//Form1.cs is one cs file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace GUICS
{
public partial class Form1 : Form
{
/*
public static void Pullout_contents(string in_file, List<string> elements)
{
StreamReader input_file = new StreamReader(in_file.ToString());
elements.Clear();
string line = "";
for (int line_no = 1; (line = input_file.ReadLine()) != null; ++line_no)
{
elements.Add(line);
}
}

public static void Show_contents(StreamWriter Out, List<string> elements)
{
foreach (string iter in elements)
{
Console.WriteLine(iter);
}
}

public static void Pushin_contents(string out_file, List<string> elements)
{
StreamWriter output_file = new StreamWriter(out_file.ToString());
output_file.AutoFlush = true;
Console.SetOut(output_file);
Show_contents(output_file, elements);// using polymorphism
}
*/
public static void MsgBox_contents(List<string> elements)
{
foreach (string iter in elements)
{
MessageBox.Show(iter);
}
}

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
/*
//StreamReader input_file = new StreamReader("test.txt");
//StreamWriter output_file = new StreamWriter("test.txt.out");
StreamReader input_file = File.OpenText("test.txt");
StreamWriter output_file = File.CreateText("test.txt.out");

String line;
while ((line = input_file.ReadLine()) != null)
{
MessageBox.Show(line);
output_file.WriteLine(line);
}

if (input_file != null)
{
input_file.Close();
output_file.Close();
}
*/

StreamReader input_file = null;
StreamWriter output_file = null;

string in_file;
in_file = "test.txt";

string out_file;
out_file = "test.txt";

List<string> elements = new List<string>();
elements.Clear();

//Pullout_contents(in_file, elements);
Header.Pullout_contents(in_file, elements);

//Pushin_contents(out_file + ".out", elements);
Header.Pushin_contents(out_file + ".out", elements);

MsgBox_contents(elements);

if (input_file != null)
{
input_file.Close();
output_file.Close();
}

}
}

#cplusplus #csharp #tutorial

Embed and Read Resource Files in Windows Form
C# Split and Merge files
Split and Merge Files with C# and Windows Forms