I am new to Visual Basic so this question may be a bit simple but it has me stumped.
I have written some visual basic code where I reference 3 text files in the same directory. When I reference the files as /filename.txt the program works but when I reference them as filename.txt the program sends up an error.
I don't understand why

Because, VB considers the source as <the path where your project file is> + the address of the text file relative to that path.. For e.g., "C:/Project"+"/txtfile.txt"

Thanks for the quick reply.
The folder of files is part of a submission to a college course. When I submitted the working files - with /filename.txt - I was told that by the recipient that he couldn't open the files and that I was wrong to reference the files like this - I should have referenced them as filename.txt.

You just reference the files as /file.txt, but ultimately the name of the file is file.txt.

Note: Mark the thread as 'solved' if it is so.

Thanks for the quick reply.
The folder of files is part of a submission to a college course. When I submitted the working files - with /filename.txt - I was told that by the recipient that he couldn't open the files and that I was wrong to reference the files like this - I should have referenced them as filename.txt.

Hi,
You can refer the filename.txt like App.Path & "\FileName.txt" Here App refers your application and App.Path refers the directory where your project file located. So App.Path will work in any machine, Whenever changing to the another computer. It wont work when the file is not in the project directory.

Comments
Good !
This article has been dead for over six months. Start a new discussion instead.