Donji video pokazuje kako da instalirate aplikaciju na početni ekran svog uređaja.
Napomena: This feature may not be available in some browsers.
Inglwood:Kada smestim neke podatke u neki fajl txt kako posle da sadrzaj tog fajla prikazem na ekranu
Inglwood:Misu cuti ako nemas sta da kazes sisaj mleko ne idi na forume
Inglwood:Kada smestim neke podatke u neki fajl txt kako posle da sadrzaj tog fajla prikazem na ekranu
Inglwood:Imam Borland C. Mislim ako napravim neki fajl i upisem podatke u njega kako da posle ucitam taj fajl i da vidim na ekranu tj da ispisem sadrzaj tog fajla (tekstualnog)?
Inglwood:prvo pisem u C#
drugo pisem dos aplikacije
i trece win32
using System;
using System.IO;
namespace ConsoleApplication
{
class MainClass
{
public void worker()
{
// name of the file to be used.
string fileName = @"c:\data.txt";
// open the file for writing.
StreamWriter sw = new StreamWriter(
new FileStream(fileName, FileMode.Create, FileAccess.Write));
// write some contents to the file.
sw.WriteLine("This is the first line of text");
sw.WriteLine("and this is the second one");
// close the file.
sw.Close();
// open the file for reading.
StreamReader sr = new StreamReader(
new FileStream(fileName, FileMode.Open, FileAccess.Read));
// load file contents into a string.
string text = "";
for (string line = sr.ReadLine(); line != null; line = sr.ReadLine())
{
text += line + System.Environment.NewLine;
}
// close the file.
sr.Close();
// display text and wait for user to press enter key.
Console.WriteLine(text);
Console.ReadLine();
}
[STAThread]
static void Main(string[] args)
{
MainClass mc = new MainClass();
mc.worker();
}
}
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace WindowsApplication
{
public class Form1 : System.Windows.Forms.Form
{
public void worker()
{
// name of the file to be used.
string fileName = @"c:\data.txt";
// open the file for writing.
StreamWriter sw = new StreamWriter(
new FileStream(fileName, FileMode.Create, FileAccess.Write));
// write some contents to the file.
sw.WriteLine("This is the first line of text");
sw.WriteLine("and this is the second one");
// close the file.
sw.Close();
// open the file for reading.
StreamReader sr = new StreamReader(
new FileStream(fileName, FileMode.Open, FileAccess.Read));
// load file contents into a string.
string text = "";
for (string line = sr.ReadLine(); line != null; line = sr.ReadLine())
{
text += line + System.Environment.NewLine;
}
// close the file.
sr.Close();
// display text.
textBox1.Text = text;
}
private System.Windows.Forms.TextBox textBox1;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
worker();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(8, 8);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBox1.Size = new System.Drawing.Size(272, 216);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "";
this.textBox1.WordWrap = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 238);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
[LynX:]malo je covek zbunjen ali ovaj forum je za to da mi nesto naucimo.
[LynX:]nisu svi ko vas "zaludzeni".
[LynX:]Mislim da to sto radite ne odgovara. Ne znam i ja bas puno (znam borland delphi i jos sitno) ali bar ne bih coveka postideo ops: kad sam vec se nahvatio da pomognem.
Inglwood:joj ipak koristim C a ne C#
#include <stdio.h>
#include <conio.h> // provides getch()
#define FILE_NAME "c:\\data.txt"
#define MAX_LINE_LEN 256
int main()
{
FILE *f; // file handle.
char fileName[] = FILE_NAME; // name of the file to be used.
char line[MAX_LINE_LEN]; // line of text.
// open the file for writing.
f = fopen(fileName, "wt");
// write some contents to the file.
fprintf(f, "This is the first line of text\n");
fprintf(f, "and this is the second one\n");
// close the file.
fclose(f);
// open the file for reading.
f = fopen(fileName, "rt");
// load file contents into a string.
while (fgets(line, sizeof(line), f) != NULL)
{
printf(line);
}
// close the file.
fclose(f);
// wait for user to press any key.
getch(); // note: getch() is defined in 'conio.h'
return 0;
}
Inglwood:Hvala Vam ovo je dobro zaista radi