Can some one help me in split operation sample to handle this case. explained below

i want to extract only file name “My Portfolio_20190809_NL01000229_EP.xlsx” from the message in save notification bar as shown in figure.

Can some one help me in split operation sample to handle this case

1 Like

Hi @KavithaManohar
Strinvar=Strvar.replace(".xlsx","")

You can get only the my portfolio_20190809_NL01000229_EP

Thanks
Ashwin.S

1 Like

kindly post the full string that you are getting…

Hi @KavithaManohar,

you can try, YourString.split((“save “,” (”),StringSplitOption.None). This will give you only the filename as output.

Check the video in the below link for your reference.

Best of luck,
Sid

1 Like

@KavithaManohar

Try this StrVar1=StrVar.Split("."c)(0)

You will get the excepted answer.

Thanks,
Mohanraj.S

1 Like

@KavithaManohar,

If the above split method is worked for you then Please mark my reply as solution in order to close the thread.

Thanks,
Mohanraj.S


It is throwing compilation error

can you please post the error…

Hi @KavithaManohar,

I didn’t understand your real situation. But I have exampled with string and array.

String variable
strResult = strVariable.Split(New String() {"("}, StringSplitOptions.None)(0)

Array Variable
ArrResult = strVariable.Split(New String() {"("}, StringSplitOptions.None)

Regards
Balamurugan.S

1 Like

@balupad14,

Ohh yeah you are correct, i forgot to mention that the result will be an array.

Sid

1 Like

Fine
hope these steps could help you resolve this
–so first to get that text either we can get from a assign activity like this
out_filename = Directory.GetFiles(“yourfolderpath”,"*.xlsx").OrderbyDescending(Funtion(d) New FileInfo(d).CreationTime).ToList(0)
where out_filename is a string variable
or
we can get that with a simple get text activity where we click on the popup and get the text we want and save it to a string variable

–i hope the first option is best and in that you are now ready with output
because it will give the file name we want

or

–if by get text with output variable in_text and split by means
out_filename = Split(in_text.Split(“save”)(1).ToString.Trim,"(")(0).ToString.Trim

this will give the file name as well

hope this would help you
kindly try this and let know for any queries or clarification
Cheers @KavithaManohar

– getting this compilation error

Tried both the ways but facing compiler issue:(

When you apply the first Split function, it returns an array, and you take the first member of that array

out_Report2.Split(“save”)(1)

Which I guess is already a string. So, is a ToString with a Trim really required?

Also, you’re taking the output from the first Split, and splitting it again with “(”

Question becomes, are you getting a Char as an output that is causing the compiler to fail on the third ToString conversion?

@KavithaManohar,

Just try the above solution i mentioned with out stringsplitoption value. Just attaching the example i tried for your reference.
image

Thanks,
sidtest.xaml (4.6 KB)

I tried by passing my string as input, but getting compilation error

– this is the compilation error

This method didn’t give me the required output

Can u provide me a sample .xaml file please so that my output will be “My portfolio_20190809_NL010010229_EP.xlsx” when my i/p string is ““Do you want to open or save My portfolio_20190809_NL010010229_EP.xlsx (126 KB) from bpr.aa.net?””

Please find the attached xaml for reference

Example.xaml (5.2 KB)

Hope this helps, cheers :smiley:

1 Like