mscorlib(4.0.0.0) API with additions
ResourceWriter.cs
1 using System.Collections;
3 using System.IO;
8 using System.Security;
10 using System.Text;
11 
12 namespace System.Resources
13 {
15  [ComVisible(true)]
17  {
18  private class PrecannedResource
19  {
20  internal string TypeName;
21 
22  internal byte[] Data;
23 
24  internal PrecannedResource(string typeName, byte[] data)
25  {
26  TypeName = typeName;
27  Data = data;
28  }
29  }
30 
31  private class StreamWrapper
32  {
33  internal Stream m_stream;
34 
35  internal bool m_closeAfterWrite;
36 
37  internal StreamWrapper(Stream s, bool closeAfterWrite)
38  {
39  m_stream = s;
40  m_closeAfterWrite = closeAfterWrite;
41  }
42  }
43 
44  private Func<Type, string> typeConverter;
45 
46  private const int _ExpectedNumberOfResources = 1000;
47 
48  private const int AverageNameSize = 40;
49 
50  private const int AverageValueSize = 40;
51 
52  private Dictionary<string, object> _resourceList;
53 
54  private Stream _output;
55 
56  private Dictionary<string, object> _caseInsensitiveDups;
57 
58  private Dictionary<string, PrecannedResource> _preserializedData;
59 
60  private const int _DefaultBufferSize = 4096;
61 
64  public Func<Type, string> TypeNameConverter
65  {
66  get
67  {
68  return typeConverter;
69  }
70  set
71  {
72  typeConverter = value;
73  }
74  }
75 
79  public ResourceWriter(string fileName)
80  {
81  if (fileName == null)
82  {
83  throw new ArgumentNullException("fileName");
84  }
85  _output = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
86  _resourceList = new Dictionary<string, object>(1000, FastResourceComparer.Default);
88  }
89 
94  public ResourceWriter(Stream stream)
95  {
96  if (stream == null)
97  {
98  throw new ArgumentNullException("stream");
99  }
100  if (!stream.CanWrite)
101  {
102  throw new ArgumentException(Environment.GetResourceString("Argument_StreamNotWritable"));
103  }
104  _output = stream;
105  _resourceList = new Dictionary<string, object>(1000, FastResourceComparer.Default);
106  _caseInsensitiveDups = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
107  }
108 
116  public void AddResource(string name, string value)
117  {
118  if (name == null)
119  {
120  throw new ArgumentNullException("name");
121  }
122  if (_resourceList == null)
123  {
124  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceWriterSaved"));
125  }
126  _caseInsensitiveDups.Add(name, null);
127  _resourceList.Add(name, value);
128  }
129 
137  public void AddResource(string name, object value)
138  {
139  if (name == null)
140  {
141  throw new ArgumentNullException("name");
142  }
143  if (_resourceList == null)
144  {
145  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceWriterSaved"));
146  }
147  if (value != null && value is Stream)
148  {
149  AddResourceInternal(name, (Stream)value, closeAfterWrite: false);
150  return;
151  }
152  _caseInsensitiveDups.Add(name, null);
153  _resourceList.Add(name, value);
154  }
155 
164  public void AddResource(string name, Stream value)
165  {
166  if (name == null)
167  {
168  throw new ArgumentNullException("name");
169  }
170  if (_resourceList == null)
171  {
172  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceWriterSaved"));
173  }
174  AddResourceInternal(name, value, closeAfterWrite: false);
175  }
176 
187  public void AddResource(string name, Stream value, bool closeAfterWrite)
188  {
189  if (name == null)
190  {
191  throw new ArgumentNullException("name");
192  }
193  if (_resourceList == null)
194  {
195  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceWriterSaved"));
196  }
197  AddResourceInternal(name, value, closeAfterWrite);
198  }
199 
200  private void AddResourceInternal(string name, Stream value, bool closeAfterWrite)
201  {
202  if (value == null)
203  {
204  _caseInsensitiveDups.Add(name, null);
205  _resourceList.Add(name, value);
206  return;
207  }
208  if (!value.CanSeek)
209  {
210  throw new ArgumentException(Environment.GetResourceString("NotSupported_UnseekableStream"));
211  }
212  _caseInsensitiveDups.Add(name, null);
213  _resourceList.Add(name, new StreamWrapper(value, closeAfterWrite));
214  }
215 
223  public void AddResource(string name, byte[] value)
224  {
225  if (name == null)
226  {
227  throw new ArgumentNullException("name");
228  }
229  if (_resourceList == null)
230  {
231  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceWriterSaved"));
232  }
233  _caseInsensitiveDups.Add(name, null);
234  _resourceList.Add(name, value);
235  }
236 
246  public void AddResourceData(string name, string typeName, byte[] serializedData)
247  {
248  if (name == null)
249  {
250  throw new ArgumentNullException("name");
251  }
252  if (typeName == null)
253  {
254  throw new ArgumentNullException("typeName");
255  }
256  if (serializedData == null)
257  {
258  throw new ArgumentNullException("serializedData");
259  }
260  if (_resourceList == null)
261  {
262  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceWriterSaved"));
263  }
264  _caseInsensitiveDups.Add(name, null);
265  if (_preserializedData == null)
266  {
267  _preserializedData = new Dictionary<string, PrecannedResource>(FastResourceComparer.Default);
268  }
269  _preserializedData.Add(name, new PrecannedResource(typeName, serializedData));
270  }
271 
275  public void Close()
276  {
277  Dispose(disposing: true);
278  }
279 
280  private void Dispose(bool disposing)
281  {
282  if (disposing)
283  {
284  if (_resourceList != null)
285  {
286  Generate();
287  }
288  if (_output != null)
289  {
290  _output.Close();
291  }
292  }
293  _output = null;
294  _caseInsensitiveDups = null;
295  }
296 
300  public void Dispose()
301  {
302  Dispose(disposing: true);
303  }
304 
309  [SecuritySafeCritical]
310  public void Generate()
311  {
312  if (_resourceList == null)
313  {
314  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceWriterSaved"));
315  }
316  BinaryWriter binaryWriter = new BinaryWriter(_output, Encoding.UTF8);
317  List<string> list = new List<string>();
318  binaryWriter.Write(ResourceManager.MagicNumber);
320  MemoryStream memoryStream = new MemoryStream(240);
321  BinaryWriter binaryWriter2 = new BinaryWriter(memoryStream);
322  binaryWriter2.Write(MultitargetingHelpers.GetAssemblyQualifiedName(typeof(ResourceReader), typeConverter));
323  binaryWriter2.Write(ResourceManager.ResSetTypeName);
324  binaryWriter2.Flush();
325  binaryWriter.Write((int)memoryStream.Length);
326  binaryWriter.Write(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
327  binaryWriter.Write(2);
328  int num = _resourceList.Count;
329  if (_preserializedData != null)
330  {
331  num += _preserializedData.Count;
332  }
333  binaryWriter.Write(num);
334  int[] array = new int[num];
335  int[] array2 = new int[num];
336  int num2 = 0;
337  MemoryStream memoryStream2 = new MemoryStream(num * 40);
338  BinaryWriter binaryWriter3 = new BinaryWriter(memoryStream2, Encoding.Unicode);
339  Stream stream = null;
340  string text = null;
341  PermissionSet permissionSet = new PermissionSet(PermissionState.None);
342  permissionSet.AddPermission(new EnvironmentPermission(PermissionState.Unrestricted));
343  permissionSet.AddPermission(new FileIOPermission(PermissionState.Unrestricted));
344  try
345  {
346  permissionSet.Assert();
347  text = Path.GetTempFileName();
348  File.SetAttributes(text, FileAttributes.Temporary | FileAttributes.NotContentIndexed);
349  stream = new FileStream(text, FileMode.Open, FileAccess.ReadWrite, FileShare.Read, 4096, FileOptions.DeleteOnClose | FileOptions.SequentialScan);
350  }
352  {
353  stream = new MemoryStream();
354  }
355  catch (IOException)
356  {
357  stream = new MemoryStream();
358  }
359  finally
360  {
362  }
363  using (stream)
364  {
365  BinaryWriter binaryWriter4 = new BinaryWriter(stream, Encoding.UTF8);
366  IFormatter objFormatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.File | StreamingContextStates.Persistence));
367  SortedList sortedList = new SortedList(_resourceList, FastResourceComparer.Default);
368  if (_preserializedData != null)
369  {
370  foreach (KeyValuePair<string, PrecannedResource> preserializedDatum in _preserializedData)
371  {
372  sortedList.Add(preserializedDatum.Key, preserializedDatum.Value);
373  }
374  }
375  IDictionaryEnumerator enumerator2 = sortedList.GetEnumerator();
376  while (enumerator2.MoveNext())
377  {
378  array[num2] = FastResourceComparer.HashFunction((string)enumerator2.Key);
379  array2[num2++] = (int)binaryWriter3.Seek(0, SeekOrigin.Current);
380  binaryWriter3.Write((string)enumerator2.Key);
381  binaryWriter3.Write((int)binaryWriter4.Seek(0, SeekOrigin.Current));
382  object value = enumerator2.Value;
383  ResourceTypeCode resourceTypeCode = FindTypeCode(value, list);
384  Write7BitEncodedInt(binaryWriter4, (int)resourceTypeCode);
385  PrecannedResource precannedResource = value as PrecannedResource;
386  if (precannedResource != null)
387  {
388  binaryWriter4.Write(precannedResource.Data);
389  }
390  else
391  {
392  WriteValue(resourceTypeCode, value, binaryWriter4, objFormatter);
393  }
394  }
395  binaryWriter.Write(list.Count);
396  for (int i = 0; i < list.Count; i++)
397  {
398  binaryWriter.Write(list[i]);
399  }
400  Array.Sort(array, array2);
401  binaryWriter.Flush();
402  int num4 = (int)binaryWriter.BaseStream.Position & 7;
403  if (num4 > 0)
404  {
405  for (int j = 0; j < 8 - num4; j++)
406  {
407  binaryWriter.Write("PAD"[j % 3]);
408  }
409  }
410  int[] array3 = array;
411  foreach (int value2 in array3)
412  {
413  binaryWriter.Write(value2);
414  }
415  int[] array4 = array2;
416  foreach (int value3 in array4)
417  {
418  binaryWriter.Write(value3);
419  }
420  binaryWriter.Flush();
421  binaryWriter3.Flush();
422  binaryWriter4.Flush();
423  int num5 = (int)(binaryWriter.Seek(0, SeekOrigin.Current) + memoryStream2.Length);
424  num5 += 4;
425  binaryWriter.Write(num5);
426  binaryWriter.Write(memoryStream2.GetBuffer(), 0, (int)memoryStream2.Length);
427  binaryWriter3.Close();
428  stream.Position = 0L;
429  stream.CopyTo(binaryWriter.BaseStream);
430  binaryWriter4.Close();
431  }
432  binaryWriter.Flush();
433  _resourceList = null;
434  }
435 
436  private ResourceTypeCode FindTypeCode(object value, List<string> types)
437  {
438  if (value == null)
439  {
440  return ResourceTypeCode.Null;
441  }
442  Type type = value.GetType();
443  if (type == typeof(string))
444  {
445  return ResourceTypeCode.String;
446  }
447  if (type == typeof(int))
448  {
449  return ResourceTypeCode.Int32;
450  }
451  if (type == typeof(bool))
452  {
453  return ResourceTypeCode.Boolean;
454  }
455  if (type == typeof(char))
456  {
457  return ResourceTypeCode.Char;
458  }
459  if (type == typeof(byte))
460  {
461  return ResourceTypeCode.Byte;
462  }
463  if (type == typeof(sbyte))
464  {
465  return ResourceTypeCode.SByte;
466  }
467  if (type == typeof(short))
468  {
469  return ResourceTypeCode.Int16;
470  }
471  if (type == typeof(long))
472  {
473  return ResourceTypeCode.Int64;
474  }
475  if (type == typeof(ushort))
476  {
477  return ResourceTypeCode.UInt16;
478  }
479  if (type == typeof(uint))
480  {
481  return ResourceTypeCode.UInt32;
482  }
483  if (type == typeof(ulong))
484  {
485  return ResourceTypeCode.UInt64;
486  }
487  if (type == typeof(float))
488  {
489  return ResourceTypeCode.Single;
490  }
491  if (type == typeof(double))
492  {
493  return ResourceTypeCode.Double;
494  }
495  if (type == typeof(decimal))
496  {
497  return ResourceTypeCode.Decimal;
498  }
499  if (type == typeof(DateTime))
500  {
501  return ResourceTypeCode.DateTime;
502  }
503  if (type == typeof(TimeSpan))
504  {
505  return ResourceTypeCode.TimeSpan;
506  }
507  if (type == typeof(byte[]))
508  {
509  return ResourceTypeCode.ByteArray;
510  }
511  if (type == typeof(StreamWrapper))
512  {
513  return ResourceTypeCode.Stream;
514  }
515  string text;
516  if (type == typeof(PrecannedResource))
517  {
518  text = ((PrecannedResource)value).TypeName;
519  if (text.StartsWith("ResourceTypeCode.", StringComparison.Ordinal))
520  {
521  text = text.Substring(17);
522  return (ResourceTypeCode)Enum.Parse(typeof(ResourceTypeCode), text);
523  }
524  }
525  else
526  {
527  text = MultitargetingHelpers.GetAssemblyQualifiedName(type, typeConverter);
528  }
529  int num = types.IndexOf(text);
530  if (num == -1)
531  {
532  num = types.Count;
533  types.Add(text);
534  }
535  return (ResourceTypeCode)(num + 64);
536  }
537 
538  private void WriteValue(ResourceTypeCode typeCode, object value, BinaryWriter writer, IFormatter objFormatter)
539  {
540  switch (typeCode)
541  {
542  case ResourceTypeCode.Null:
543  break;
544  case ResourceTypeCode.String:
545  writer.Write((string)value);
546  break;
547  case ResourceTypeCode.Boolean:
548  writer.Write((bool)value);
549  break;
550  case ResourceTypeCode.Char:
551  writer.Write((ushort)(char)value);
552  break;
553  case ResourceTypeCode.Byte:
554  writer.Write((byte)value);
555  break;
556  case ResourceTypeCode.SByte:
557  writer.Write((sbyte)value);
558  break;
559  case ResourceTypeCode.Int16:
560  writer.Write((short)value);
561  break;
562  case ResourceTypeCode.UInt16:
563  writer.Write((ushort)value);
564  break;
565  case ResourceTypeCode.Int32:
566  writer.Write((int)value);
567  break;
568  case ResourceTypeCode.UInt32:
569  writer.Write((uint)value);
570  break;
571  case ResourceTypeCode.Int64:
572  writer.Write((long)value);
573  break;
574  case ResourceTypeCode.UInt64:
575  writer.Write((ulong)value);
576  break;
577  case ResourceTypeCode.Single:
578  writer.Write((float)value);
579  break;
580  case ResourceTypeCode.Double:
581  writer.Write((double)value);
582  break;
583  case ResourceTypeCode.Decimal:
584  writer.Write((decimal)value);
585  break;
586  case ResourceTypeCode.DateTime:
587  {
588  long value2 = ((DateTime)value).ToBinary();
589  writer.Write(value2);
590  break;
591  }
592  case ResourceTypeCode.TimeSpan:
593  writer.Write(((TimeSpan)value).Ticks);
594  break;
595  case ResourceTypeCode.ByteArray:
596  {
597  byte[] array2 = (byte[])value;
598  writer.Write(array2.Length);
599  writer.Write(array2, 0, array2.Length);
600  break;
601  }
602  case ResourceTypeCode.Stream:
603  {
604  StreamWrapper streamWrapper = (StreamWrapper)value;
605  if (streamWrapper.m_stream.GetType() == typeof(MemoryStream))
606  {
607  MemoryStream memoryStream = (MemoryStream)streamWrapper.m_stream;
608  if (memoryStream.Length > int.MaxValue)
609  {
610  throw new ArgumentException(Environment.GetResourceString("ArgumentOutOfRange_StreamLength"));
611  }
612  memoryStream.InternalGetOriginAndLength(out int origin, out int length);
613  byte[] buffer = memoryStream.InternalGetBuffer();
614  writer.Write(length);
615  writer.Write(buffer, origin, length);
616  break;
617  }
618  Stream stream = streamWrapper.m_stream;
619  if (stream.Length > int.MaxValue)
620  {
621  throw new ArgumentException(Environment.GetResourceString("ArgumentOutOfRange_StreamLength"));
622  }
623  stream.Position = 0L;
624  writer.Write((int)stream.Length);
625  byte[] array = new byte[4096];
626  int num = 0;
627  while ((num = stream.Read(array, 0, array.Length)) != 0)
628  {
629  writer.Write(array, 0, num);
630  }
631  if (streamWrapper.m_closeAfterWrite)
632  {
633  stream.Close();
634  }
635  break;
636  }
637  default:
638  objFormatter.Serialize(writer.BaseStream, value);
639  break;
640  }
641  }
642 
643  private static void Write7BitEncodedInt(BinaryWriter store, int value)
644  {
645  uint num;
646  for (num = (uint)value; num >= 128; num >>= 7)
647  {
648  store.Write((byte)(num | 0x80));
649  }
650  store.Write((byte)num);
651  }
652  }
653 }
Represents a character encoding.To browse the .NET Framework source code for this type,...
Definition: Encoding.cs:15
virtual void Close()
Closes the current T:System.IO.BinaryWriter and the underlying stream.
virtual Stream BaseStream
Gets the underlying stream of the T:System.IO.BinaryWriter.
Definition: BinaryWriter.cs:44
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static void SetAttributes(string path, FileAttributes fileAttributes)
Sets the specified T:System.IO.FileAttributes of the file on the specified path.
Definition: File.cs:911
void AddResource(string name, Stream value, bool closeAfterWrite)
Adds a named resource specified as a stream to the list of resources to be written,...
override long Length
Gets the length of the stream in bytes.
abstract int Read([In] [Out] byte[] buffer, int offset, int count)
When overridden in a derived class, reads a sequence of bytes from the current stream and advances th...
TValue Value
Gets the value in the key/value pair.
Definition: KeyValuePair.cs:32
Provides the base functionality for writing resources to an output file or stream.
bool MoveNext()
Advances the enumerator to the next element of the collection.
FileOptions
Represents advanced options for creating a T:System.IO.FileStream object.
Definition: FileOptions.cs:9
int Count
Gets the number of elements contained in the T:System.Collections.Generic.List`1.
Definition: List.cs:296
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
virtual void Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
object Key
Gets the key of the current dictionary entry.
FileMode
Specifies how the operating system should open a file.
Definition: FileMode.cs:8
static Encoding Unicode
Gets an encoding for the UTF-16 format using the little endian byte order.
Definition: Encoding.cs:975
void Serialize(Stream serializationStream, object graph)
Serializes an object, or graph of objects with the given root to the provided stream.
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
Definition: IDisposable.cs:8
FileAttributes
Provides attributes for files and directories.
Definition: __Canon.cs:3
abstract bool CanWrite
When overridden in a derived class, gets a value indicating whether the current stream supports writi...
Definition: Stream.cs:610
void AddResource(string name, byte[] value)
Adds a named resource specified as a byte array to the list of resources to be written.
void AddResource(string name, object value)
Adds a named resource specified as an object to the list of resources to be written.
void Dispose()
Allows users to close the resource file or stream, explicitly releasing resources.
static string GetTempFileName()
Creates a uniquely named, zero-byte temporary file on disk and returns the full path of that file.
Definition: Path.cs:1020
Describes the source and destination of a given serialized stream, and provides an additional caller-...
Represents a resource manager that provides convenient access to culture-specific resources at run ti...
A type representing a date and time value.
ResourceWriter(Stream stream)
Initializes a new instance of the T:System.Resources.ResourceWriter class that writes the resources t...
Serializes and deserializes an object, or an entire graph of connected objects, in binary format.
virtual void Add(object key, object value)
Adds an element with the specified key and value to a T:System.Collections.SortedList object.
Definition: SortedList.cs:806
IPermission AddPermission(IPermission perm)
Adds a specified permission to the T:System.Security.PermissionSet.
SeekOrigin
Specifies the position in a stream to use for seeking.
Definition: SeekOrigin.cs:9
virtual long Seek(int offset, SeekOrigin origin)
Sets the position within the current stream.
virtual byte [] GetBuffer()
Returns the array of unsigned bytes from which this stream was created.
Defines a key/value pair that can be set or retrieved.
Definition: KeyValuePair.cs:10
void Generate()
Saves all resources to the output stream in the system default format.
void Add(T item)
Adds an object to the end of the T:System.Collections.Generic.List`1.
Definition: List.cs:510
TKey Key
Gets the key in the key/value pair.
Definition: KeyValuePair.cs:20
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
virtual void Close()
Closes the current stream and releases any resources (such as sockets and file handles) associated wi...
Definition: Stream.cs:855
ResourceWriter(string fileName)
Initializes a new instance of the T:System.Resources.ResourceWriter class that writes the resources t...
Creates a stream whose backing store is memory.To browse the .NET Framework source code for this type...
Definition: MemoryStream.cs:13
static void Sort(Array array)
Sorts the elements in an entire one-dimensional T:System.Array using the T:System....
Definition: Array.cs:3259
Represents a collection that can contain many different types of permissions.
Provides functionality for formatting serialized objects.
Definition: IFormatter.cs:8
void Close()
Saves the resources to the output stream and then closes it.
int Count
Gets the number of key/value pairs contained in the T:System.Collections.Generic.Dictionary`2.
Definition: Dictionary.cs:890
Provides a T:System.IO.Stream for a file, supporting both synchronous and asynchronous read and write...
Definition: FileStream.cs:15
void AddResource(string name, Stream value)
Adds a named resource specified as a stream to the list of resources to be written.
static readonly int HeaderVersionNumber
Specifies the version of resource file headers that the current implementation of T:System....
void AddResourceData(string name, string typeName, byte[] serializedData)
Adds a unit of data as a resource to the list of resources to be written.
The exception that is thrown when an I/O error occurs.
Definition: IOException.cs:10
void CopyTo(Stream destination)
Reads the bytes from the current stream and writes them to another stream.
Definition: Stream.cs:778
Represents a collection of key/value pairs that are sorted by the keys and are accessible by key and ...
Definition: SortedList.cs:14
Func< Type, string > TypeNameConverter
Gets or sets a delegate that enables resource assemblies to be written that target versions of the ....
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition: Array.cs:17
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
void AddResource(string name, string value)
Adds a string resource to the list of resources to be written.
virtual void Write(bool value)
Writes a one-byte Boolean value to the current stream, with 0 representing false and 1 representing t...
Enumerates the resources in a binary resources (.resources) file by reading sequential resource name/...
The exception that is thrown when one of the arguments provided to a method is not valid.
abstract long Length
When overridden in a derived class, gets the length in bytes of the stream.
Definition: Stream.cs:621
Writes resources in the system-default format to an output file or an output stream....
Attribute can be applied to an enumeration.
PermissionState
Specifies whether a permission should have all or no access to resources at creation.
FileAccess
Defines constants for read, write, or read/write access to a file.
Definition: FileAccess.cs:9
object Value
Gets the value of the current dictionary entry.
int IndexOf(T item)
Searches for the specified object and returns the zero-based index of the first occurrence within the...
Definition: List.cs:1075
static readonly int MagicNumber
Holds the number used to identify resource files.
abstract long Position
When overridden in a derived class, gets or sets the position within the current stream.
Definition: Stream.cs:633
Enumerates the elements of a nongeneric dictionary.
static Encoding UTF8
Gets an encoding for the UTF-8 format.
Definition: Encoding.cs:1023
static StringComparer OrdinalIgnoreCase
Gets a T:System.StringComparer object that performs a case-insensitive ordinal string comparison.
The exception that is thrown when a method call is invalid for the object's current state.
Provides static methods for the creation, copying, deletion, moving, and opening of a single file,...
Definition: File.cs:14
void Add(TKey key, TValue value)
Adds the specified key and value to the dictionary.
Definition: Dictionary.cs:1244
Controls access to system and user environment variables. This class cannot be inherited.
void Assert()
Declares that the calling code can access the resource protected by a permission demand through the c...
The exception that is thrown when the operating system denies access because of an I/O error or a spe...
StreamingContextStates
Defines a set of flags that specifies the source or destination context for the stream during seriali...
Controls the ability to access files and folders. This class cannot be inherited.
static void RevertAssert()
Causes any previous M:System.Security.CodeAccessPermission.Assert for the current frame to be removed...
Writes primitive types in binary to a stream and supports writing strings in a specific encoding.
Definition: BinaryWriter.cs:12
Performs operations on T:System.String instances that contain file or directory path information....
Definition: Path.cs:13
Represents a string comparison operation that uses specific case and culture-based or ordinal compari...
FileShare
Contains constants for controlling the kind of access other T:System.IO.FileStream objects can have t...
Definition: FileShare.cs:9
Provides a generic view of a sequence of bytes. This is an abstract class.To browse the ....
Definition: Stream.cs:16