Location

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
izidor
Veteran
Posts: 110
Joined: Wed Apr 22, 2009 3:13 am
Contact:

Location

Post by izidor »

Lets say that i have folder named text and in it there is text.txt.Here is my question how to open file from specific folder without writing "C:\..." or "D:\..."?
User avatar
bongomeno
Veteran
Posts: 266
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

Post by bongomeno »

unless it is in the same folder as the program opening it, the file must have the C:\whatever\.

if the program is trying to access a file within a folder in the programs folder then you can do it like this (assuming your prog is in c:\f\) -

c:\f\folder\file.ext
OR
\folder\file.ext
izidor
Veteran
Posts: 110
Joined: Wed Apr 22, 2009 3:13 am
Contact:

Post by izidor »

Thanks for reply. When i was searching net i found another solution command CHDIR.
User avatar
DDastardly71
Coder
Posts: 22
Joined: Fri Oct 17, 2008 6:56 pm
Location: U.S.A.

Post by DDastardly71 »

If the folder is in the same directory as your program, you can use relative instead of absolute path and without using CHDIR.

Works...
OPEN "text\text.txt" FOR INPUT AS #1

Will not work...this is an incomplete path as shown from the previous reply.
OPEN "\text\text.txt" FOR INPUT AS #1
Post Reply