-
Notifications
You must be signed in to change notification settings - Fork 56
/
Program.cs
52 lines (46 loc) · 1.91 KB
/
Program.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.IO;
namespace FilesAndDirectories
{
class Program
{
static void Main(string[] args)
{
using (FileStream fs = File.Create("foo.bar"))
{
}
// Equivalent code without using File class
using (var fs = new FileStream("foo.bar", FileMode.Create,
FileAccess.ReadWrite, FileShare.None))
{
}
foreach (string file in Directory.GetFiles(@"c:\users\ian\Pictures",
"*.jpg",
SearchOption.AllDirectories))
{
Console.WriteLine(file);
}
var fi = new FileInfo(@"c:\temp\log.txt");
Console.WriteLine(
$"{fi.FullName} ({fi.Length} bytes) last modified on {fi.LastWriteTime}");
string appSettingsRoot =
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string myAppSettingsFolder =
Path.Combine(appSettingsRoot, @"Endjin\FrobnicatorPro");
}
}
// Members of FileStream for illustration purposes only. These are defined by .NET so
// we don't need to define them ourselves.
#if false
public FileStream(string path, FileMode mode)
public FileStream(string path, FileMode mode, FileAccess access)
public FileStream(string path, FileMode mode, FileAccess access,
FileShare share)
public FileStream(string path, FileMode mode, FileAccess access,
FileShare share, int bufferSize);
public FileStream(string path, FileMode mode, FileAccess access,
FileShare share, int bufferSize, bool useAsync);
public FileStream(string path, FileMode mode, FileAccess access,
FileShare share, int bufferSize, FileOptions options);
#endif
}