How to cut a String in VB.NET? - vb.net

I have that string ...
C:\Users\ApplicationData\Folder1\Myapp.exe
How could i cut like:
C:\Users\ApplicationData\Folder1
I have tried s.split("\Myapp.exe") , where s is C:\Users\ApplicationData\Folder1\Myapp.exe
Plase help me, thanks.

Use the Path class:
Path.GetDirectoryName("C:\Users\ApplicationData\Folder1\Myapp.exe")
Check it here:
http://msdn.microsoft.com/en-us/library/system.io.path.getdirectoryname.aspx

you can use the System.IO.FileInfo class.
It contains a function FullName, which returns the directory full name.
check this link

Related

SQL: regex for removing certain part of a string

How can I remove {color:#de350b} and {color} from:
{color:#de350b}FA_RDA_CORE-DEC-20220325122114-210-981{color}
to get:
FA_RDA_CORE-DEC-20220325122114-210-981
Good day.
Can you try this? Please don't forget substitution with "$5".
Regex101ttps://regex101.com/r/aDJzUf/1

How do I save a pdf with a custom file name

Im new to python and can't figure out how to save my pdf file with a custom name.
What I want to do is something like:
Name = input('What is your name: ')
pdf.output('Name.pdf')
And as I expected the name of the pdf file created is now: Name
I tried searching for it but I think im using the wrong words for it since I can't find a solution for my problem. I might be explaning it badly. But if anyone got an answer for it it would be much appreciated :)
Sir, in your question:
pdf.output('Name.pdf')
Here you are passing Name.pdf as a string to the output function if you want to pass the Name variable you should not use ' quotes around the value you are passing you final code should look something like this:
name = input("Enter your name: ")
name = name + ".pdf" //adds .pdf extension to the name entered
pdf.output(name) //see how there are no quotes around name variable

Velocity trim() method

For example
$xcontext.user -> Xwiki.user.trim('Xwiki')
"XWiki." How can I remove the expression?
I tried this but it did not work.
Just extract the page name (i.e. profile page name) from the current user's reference. It's the best way and you avoid String manipulation:
$xcontext.userReference.name

attach_file option in Helium Scripts

I am pretty new in Helium Scripts. I am trying to use attach_file option as mentioned in API documentation of Helium. But it does not attach the file.
Syntax I am using: attach_file("C:\xxx/xxx.csv", to="File name:")
Please guide me.
Thanks
SP
Well the way you are trying to attach a file is not right. The right approach should be following
attachFile("c:/test.txt", to("Please select a file:"));
So in the above syntax attach_file this should be attachFile
("C:\xxx/xxx.csv", follow C:/xxx/xxx.csv format
to="File name:" Here instead of file name there should be String, WebElement, HTMLElement or Point )
So the final findings is syntax for attaching file is attachFile("file path from where you want to attach", to("WebElement, HTMLElement or Point" where you want to submit))
in case anybody needs it now for Python. This is an excerpt from helium docstring:
attach_file("c:/test.txt", to="Please select a file:")

ASP.NET MVC3 Razor #string dot problem

With the MVC3 Razor synax, one may render a string like so
#ViewData("photo")
My problem is: How can I append a dot to the above code.
The following will result in a "Public member 'jpg' on type 'String' not found.":
#ViewData("photo").jpg
I've tried the following code but does not produce my intended result:
#ViewData("photo") .jpg
#ViewData("photo"):.jpg
#ViewData("photo") & ".jpg"
Thanx for advance for your help.
And please dont advice me to append the "jpg" in the controller's code like so:
ViewData("photo") = "filename.jpg"
I've searched the Net for the same problem but found none, not even something
similar.
By the way, I'm using VB.net.
How about this?
#(ViewData("photo")).jpg
Edit: And with the dynamic ViewBag:
#(ViewBag.photo).jpg
Adding as answer:
#(ViewData("photo") + ".jpg")
You could always try:
#string.concat(ViewData("photo"),".jpg")