var fdoc = new FileDocumentLib.FileDocument();
fdoc.Open(@"c:\temp\file1");
// perform modifications to the file and save it
fdoc.Save(false);
// prepare the object to work with a next document
fdoc.Close();
fdoc.Open(@"c:\temp\file2");
// ...

Opens an existing document. Hex Editor Neo tries to get a read-only access to the file. It also denies write access to all future open attempts, until the file is closed.

Complexity: constant-time.

If supported by the file system, the name may be actually the name of the alternate data stream. Hex Editor Neo fully supports NTFS alternate data streams. You may use any method provided by the object after opening the file stream. Note however, that there are few limitations that are described in the IFileDocument.Save method section.

SaveAs

SaveAs(FileName: string): void;

void SaveAs(string FileName);

HRESULT SaveAs(_bstr_t FileName);

FileName

Full name of the file to write

Saves the file with a different name. The Save As command does not drop a document's operation history. Passing the name of an NTFS alternate data stream to this method is an error and leads to undefined behavior.

The multiple selection object, which contains the ranges to fill in the document.

Continue

True to continue filling in a new range and False to start from the beginning of the pattern. See the description of the “Transparent fill” flag in the Fill user-interface command for more information.

Fills a given multiple selection with a specified pattern. The pattern is repeated until all given range(s) are filled. bCont parameter specifies whether to continue filling a new range from the previous range, or from the beginning of the pattern.

Writes data to a document. The written data overwrites document's existing data and may also increase the file's size if it overlaps the current file's size. Write always creates a new operation in document's operation history.

Copies the given selection to the Clipboard and removes it from the document.

Complexity: linear-time, depending on the selection's complexity.

Cutting document's data to the Clipboard

// fdoc is defined and obtained elsewhere
var msel = fdoc.CreateEmptySelection(); // create an empty selection object
msel.AddRange(100, 20); // add a first range to the selection
msel.AddRange(200, 20); // add a second range to the selection
fdoc.Cut(msel, false); // place data to the clipboard

Paste

Paste(Offset: number, InsertMode: boolean): void;

void Paste(ulong Offset, bool InsertMode);

HRESULT Paste(unsigned long long Offset, VARIANT_BOOL InsertMode);

Offset

Paste offset

InsertMode

true to insert data, false to overwrite data.

Pastes data from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode parameter.

Type of text in the Clipboard. Used only if Clipboard contains textual data, otherwise ignored. Can be one of the values from TextType enumeration. A number may be prefixed by the 0x prefix which forces it to be in base 16.

InsertMode

true to insert data, false to overwrite data.

Pastes data from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode parameter.

Type of text in the Clipboard. Used only if Clipboard contains textual data, otherwise ignored. Can be one of the values from TextType enumeration. A number may be prefixed by the 0x prefix which forces it to be in base 16.

Flags

Pasting flags. Can be one or more values from the Paste3Flags enumeration.

Pastes data from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode flag in Flags parameter.

Pastes text from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode parameter.

Unicode parameter tells the Hex Editor Neo to interpret the text in the Clipboard as UNICODE or ANSI. If Unicode is true, each character occupies two bytes, otherwise, it occupies a single byte.

PasteText2

HRESULT PasteText2(unsigned long long Offset, unsigned long CodePage, VARIANT_BOOL InsertMode);

Offset

Paste offset

CodePage

The code page to convert text to. Set to CP_UNICODE (hardcoded as -5) to specify UTF-16 encoding.

InsertMode

True to insert data, False to overwrite data.

Pastes text from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode parameter.

Hex Editor Neo uses the CodePage to convert the text in the Clipboard. Pass the CP_UNICODE (hardcoded as -5) to specify the UTF-16 encoding.

This method requires the CF_UNICODETEXT format to be present in the Clipboard in order to convert to the given encoding. If only CF_TEXT is available, than it operates exactly like the IFileDocument.PasteText method.

Multiple selection object, which contains ranges in which you want to locate a pattern.

StartFrom

Offset from which you want to start searching.

SearchUp

true to search backwards and false to search forward.

ignore_case

true to ignore case and false to perform exact matching.

Offset of the located pattern or -1 if pattern was not found.

Searches for a pattern within a given selection. This method returns the offset of the matched pattern. To continue searching, call this method again, adjusting StartFrom parameter appropriately. If pattern is not found in the specified range, -1 is returned.

Complexity: linear-time, depending on the file's size and selection's complexity.

HRESULT FindRegExp(_bstr_t RegExp,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long StartFrom,
unsigned long long Size,
unsigned long long * FoundOffset,
unsigned long long * MatchSize);

RegExp

A string that contains a regular expression. A regular expression must by in ECMAScript syntax.

SubExpression

The number of sub-match to search for. 0 means the entire expression.

Flags

Flags that change the behavior of the function. May be one or more of values from RegExpFlags enumeration.

StartFrom

A start offset of the range. Must be a multiple of 2 if RegExpTypeUNICODE flag is specified.

Size

Range's size. Must be a multiply of 2 if RegExpTypeUNICODE flag is specified.

FoundOffset

On output, the found offset is stored in this parameter.

MatchSize

On output, the match's size is stored in this parameter.

Searches for an occurrence of a regular expression within a given range. To continue searching, call this method again, adjusting StartFrom field appropriately. If a pattern is not found in the specified range, this method returns an error.

Complexity: depends on the range's size and regular expression complexity.

HRESULT FindRegExp2(_bstr_t RegExp,
unsigned long CodePage,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long StartFrom,
unsigned long long Size,
unsigned long long * FoundOffset,
unsigned long long * MatchSize);

RegExp

A string that contains a regular expression. A regular expression must by in ECMAScript syntax.

Flags that change the behavior of the function. May be a combination of values from the RegExpFlags enumeration.

StartFrom

A start offset of the range. Must be a multiple of 2 if RegExpTypeUNICODE flag is specified.

Size

Range's size. Must be a multiply of 2 if RegExpTypeUNICODE flag is specified.

FoundOffset

On output, the found offset is stored in this parameter.

MatchSize

On output, the match's size is stored in this parameter.

Searches for an occurrence of a regular expression within a given range. To continue searching, call this method again, adjusting StartFrom field appropriately. If a pattern is not found in the specified range, this method returns an error.

Complexity: depends on the range's size and regular expression complexity.

Multiple Selection object, which contains ranges in which a pattern need to be located.

IgnoreCase

true to ignore case, false to perform exact matching.

Found

Multiple Selection object, which contains, on method's return, all located ranges.

Locates all occurrences of a given pattern within a given multiple selection. You provide the function with an output Multiple Selection ObjectFound, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences.

Complexity: linear-time, depending on the file's size and selection's complexity.

A string that contains a regular expression. A regular expression must by in ECMAScript syntax.

SubExpression

The number of sub-match to search for. 0 means the entire expression.

Flags

Flags that change the behavior of the function. May be one or more values from the RegExpFlags enumeration.

StartFrom

A start offset of the range. Must be a multiple of 2 if RegExpTypeUNICODE flag is specified.

Size

Range's size. Must be a multiply of 2 if RegExpTypeUNICODE flag is specified.

Found

Multiple Selection object, which contains, on method's return, all located ranges.

A number of occurrences

Locates all matches of a given regular expression in a given range. You provide the function with an output Multiple Selection ObjectFound, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences.

Complexity: depends on the range's size and regular expression complexity.

Flags that change the behavior of the function. May be one or more values from the RegExpFlags enumeration.

StartFrom

A start offset of the range. Must be a multiple of 2 if RegExpTypeUNICODE flag is specified.

Size

Range's size. Must be a multiply of 2 if RegExpTypeUNICODE flag is specified.

Found

Multiple Selection object, which contains, on method's return, all located ranges.

A number of occurrences.

Locates all matches of a given regular expression in a given range. You provide the function with an output Multiple Selection ObjectFound, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences.

Complexity: depends on the range's size and regular expression complexity.

HRESULT PatternStatisticsRegExp(_bstr_t RegExp,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long * DataBuffer,
unsigned long Blocks,
unsigned long long StartFrom,
unsigned long long Size);

RegExp

A string that contains a regular expression. A regular expression must by in ECMAScript syntax.

SubExpression

The number of sub-match to search for. 0 means the entire expression.

Flags

Flags that change the behavior of the function. May be one or more of the values from the RegExpFlags enumeration.

DataBuffer

Pointer to the statistics buffer.

Blocks

Number of blocks.

StartFrom

A start offset of the range. Must be a multiple of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.

Size

Range's size. Must be a multiply of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.

Calculates file statistics for a given regular expression. See the Pattern Statistics section for more information. On method return, the DataBuffer buffer is filled with calculated statistics values.

HRESULT PatternStatisticsRegExp2(_bstr_t RegExp,
unsigned long CodePage,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long * DataBuffer,
unsigned long Blocks,
unsigned long long StartFrom,
unsigned long long Size);

RegExp

A string that contains a regular expression. A regular expression must by in ECMAScript syntax.

The multiple selection object, which contains the ranges to fill in the document.

Continue

True to continue filling in a new range and False to start from the beginning of the pattern. See the description of the “Transparent fill” flag in the Fill user-interface command for more information.

Fills a given multiple selection with a specified pattern. The pattern is repeated until all given range(s) are filled. Continue parameter specifies whether to continue filling a new range from the previous range, or from the beginning of the pattern.

Multiple Selection object, which contains ranges in which a pattern need to be located

IgnoreCase

true to ignore case, false to perform exact matching.

Found

Multiple Selection Object, which contains, on method's return, all located ranges.

Locates all occurrences of a given pattern within a given multiple selection. You provide the function with an output Multiple Selection ObjectFound, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences.

Complexity: linear-time, depending on the file's size and selection's complexity.

Multiple selection object, which contains ranges in which you want to locate a pattern.

StartFrom

Offset from which you want to start searching.

SearchUp

true to search backwards and false to search forward.

IgnoreCase

true to ignore case and false to perform exact matching.

Offset of the located pattern or -1 if pattern was not found.

Searches for a pattern within a given selection. This method returns the offset of the matched pattern. To continue searching, call this method again, adjusting StartFrom field appropriately. If pattern is not found in the specified range, -1 is returned.

Complexity: linear-time, depending on the file's size and selection's complexity.

Converts 64-bit integer into scripting compatible integer. Hex Editor Neo extensively uses 64-bit integer numbers. Scripting languages do not directly support such values, so this method may be used to convert them to supported decimal type.

WriteS

WriteS(Sequence: ${ISequence}, Offset: number): void;

// This method is not available in managed environment

// This method is not available in native environment

Sequence

Sequence object that contains the data to write.

Offset

Write offset

Writes data to a document. The written data overwrites document's existing data and may also increase the file's size if it overlaps the current file's size. Write always creates a new operation in document's operation history.