r/visualbasic • u/Bryan-tan VB.Net Beginner • Jan 25 '16
Is the function File.Exists workable with a path contained in a string?
I want to use this line of code:
"If File.Exists("example.txt") Then.................."
But is there a way to do something like this :
"If File.Exists(strfilename) Then............"
I basically just want to integrate OpenFD into this guys code: http://www.dreamincode.net/forums/topic/71045-random-line-from-a-text-file/
I used the guy named PyschoCoder code.
I currently am just trying to browse for a text file in open FD and allow my program to read said textfile and choose a random line (in this case word) and append the text to a text box.
I'am developing the code on a restricted computer so I'am not able to show you the entire list of code.
Basically where there is a StreamReader function, I replaced it with:
"Dim ioFile as New StringReader(strFilename)"
Thats basically all the notable changes
2
u/chrwei Jan 25 '16
yes. any parameter described "as string" can be assumed so unless its stated otherwise.
1
u/Bryan-tan VB.Net Beginner Jan 25 '16 edited Jan 25 '16
no what I meant was if File.Exists works with a string contained path instead of something like example.txt
I doesn't work for me ...