Microsoft Dynamics NAV: Ends with what character?

When working with the files, either for importing, exporting or saving, along with the filename (i.e. abcdef.txt) the file path (i.e. c:\temp\) needs to be specified. The path and filename combined (i.e. c:\temp\absdef.txt) is the absolute path.

In most cases this path is specified in a “setup”. As part of a “setup” this path is often manually entered and may be entered either as “c:\temp” or “c:\temp\”. Combining this path with a filename can lead to some mixed results as “c:\temp\abcdef.txt” and “c:\tempabcdef.txt” are not the same. How do we know if the path text ends with a specific character? In Microsoft Dynamics NAV there isn’t an “EndsWith” function available to pass the text into. However, there is an EndsWith Method in the String Class that we can easily incorporate into Microsoft Dynamics NAV with dotNET Interop.

```Name			DataType	Subtype
NetString DotNet		System.String.'mscorlib'
```
```EndsWith(string : Text[250];endswith : Text[5]) : Boolean
//string: is the text value to examine
//endswith: is the text value to compare

NetString := string;
EXIT (NetString.EndsWith(endswith));
```