-
Notifications
You must be signed in to change notification settings - Fork 37
/
FileExample.cs
34 lines (31 loc) · 1.17 KB
/
FileExample.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//____________________________________________________________________________________________________________________________________
//
// Copyright (C) 2023, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community by pressing the `Watch` button and get started commenting using the discussion panel at
//
// https://github.com/mpostol/TP/discussions/182
//
// by introducing yourself and telling us what you do with this community.
//_____________________________________________________________________________________________________________________________________
using System;
using System.Globalization;
using System.IO;
using System.Text;
namespace TP.DataStreams.FileAndStream
{
public class FileExample
{
public void CreateTextFile(string name)
{
File.Delete(name);
using (Stream _stream = File.Open(name, FileMode.OpenOrCreate, FileAccess.Write))
{
FileContent = String.Format(CultureInfo.InvariantCulture, "Today is {0}", DateTime.Now);
byte[] _content = Encoding.ASCII.GetBytes(FileContent);
_stream.Write(_content, 0, _content.Length);
}
}
public string FileContent { get; private set; }
}
}