how do I get the text form Inputfield

I want to get the text from InputField and store it,

I’ve tried this :

InputField = folder name;

void start(){
foldername = foldername.GetComponent InputField>();

My question is how do I get that text, do I have to store it in a string var?

the easiest way is like this.

string  myText =  GetComponent<InputField().text;

be sure to look through this too:
https://docs.unity3d.com/ScriptReference/UI.InputField.html

Hope it helps