Variables in a file path using IO.StreamWriter

hardrain02

New member
Joined
Mar 13, 2010
Messages
2
Programming Experience
Beginner
Hi, I have searched the web for an answer to this but can not find one anywhere. I have a program that will be sending text to different text files based on a selection in some combo boxes, I was wondering if it is possible to select the file path based on the combo box variables eg

if the user selects hello and then 4 in the combo boxes then the text will be saved to

w = New IO.StreamWriter("c:\project\hello\4.txt")

or if they select hi and 5

w = New IO.StreamWriter("c:\project\hi\5.txt")

i have tried setting 2 variables called a and b and trying to run the following

w = New IO.StreamWriter("c:\project\{a}\{b}.txt")
but this does not work

does anyone know if this is possible, thanks in advance for any help you can give

Hardrain02
 
Something like this:
VB.NET:
Dim w As New StreamWriter(String.Format("C:\projects\{0}\{1}.txt", combobox1.Text, combobox2.Text))
 
Back
Top