简体   繁体   中英

Get filename in Dynamics Ax

I need to extract a file name from complete path and I see it strange that I when I split the path, I need to iterate through the list to get the file name. Why can't I just get the value simply by calling myList(3) as in DotNet, instead of having to instantiate an iterator, then loop through the records.

Here is my code;

 List strlist=new List(Types::String); 
 strlist = strSplit(CompletePath, @"\");

After doing this I should have a list of all the different parts. Is there any simple form to read the list, like FileName = strlist[2]; instead of having to do the below;

iterator = new ListIterator(strlist);
while(iterator.more())
{
FileName = iterator.value();
if (_Value == "myFile")
{
 _NotFound=boolean::false;
}

Here again, if at that very moment, I don't know the file name, how do I check?

Thanks in anticipation for your support.

Global::fileNameSplit(fileName)

returns a container [path, file name, extension]

Should be used over the .NET methods recommended by Matej.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM