ClassPath: MEng.System.Runtime.FileInStream Parent ClassPath: MEng.System.Runtime.TextInStream Copyable: No Final: Yes MEng.System.Runtime.FileInStream is a derivative of the base text input stream. This class provides the base class' input stream functionality over a text file. So it will pull in text from a disk file. This class inherits almost all of it's functionality from the parent class, and just provides the ability to have that base functionality work in terms of a file. All that is provided here is the stuff required to manage the file that provides the input.
Note that the Open() method must be called before you can stream in text, else an exception will be thrown. You can close the stream and re-open it on another file if desired
File streams can support many different text encodings, so you must set the encoding you want to use. If you use the default constructor, you will get a default US-ASCII transcoder. There is a second constructor that allows you to indicate some other encoding. See the TextXCoder class for a list of valid encoding name aliases.
Constructors:
Constructor(); Constructor([In] MEng.String Encoding);The default constructor sets up the stream for a default US-ASCII text format. The second constructor allows you to indicate a particular encoding.
Final, Const Methods:
GetFileName() Returns MEng.String;Returns the file name of the currently open file. If the file isn't open, the return is meaningless.
Final, Non-Const Methods:
Close();Closes the current file, if any. The stream can be reopened on another file if desired.
Open([In] MEng.String FilePath);Opens the file that will provide the underlying input buffer for this stream. The passed path must be fully qualified, meaning that it should start with a \ character, and it cannot have any ".." entries in it, i.e. it must be a fully normalized path. This prevents any attempt to use .. entries to access the file system above the restricted area reserved for CML file access.
- Note that since the \ character is the character escapement character in CML, you must use double slashes when you create a literal path, so instead of "\MyPath\MyFile.Txt" you must do "\\MyPath\\MyFile.Txt". Otherwise, the \M in MyPath and MyFile are both seen as escape characters and since M isn't any special character, the slash is just thrown away and the M kept, and you would end up with "MyPathMyFile.Txt", which is not what you want.
If the open fails, a FileSysErrors.OpenFailed exception will be thrown. The text will indicate the reason for the failure.