Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 3rd, 2003, 12:26 PM
Registered User
Join Date: Nov 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to read text files from CD?

In my program I need information from text files which are located
on CD-drive. But I have problems with running it from different
computers because the letter of CD-drive may also differ, so I don't know what path I should write into this code:

intFH = FreeFile()
Open "F:\Inf1.txt" For Input As intFH

I would like to know how to get the letter of CD-drive or full
path of current .exe-file
Thanks in advance for your help.

Old November 3rd, 2003, 12:36 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts

There are several things you can do to make you application more dynamic. But, in the interest of time I can only answer the one question you had. The application path or the path of the current exe as you put it can be retrieved from the the os using the App.Path() funtion in VB.

The application object has many members one of them is the Path. This will return the path where the application exe is located and running.

 Dim strCurrentPath as String

 strCurrentPath = App.Path

Give it a try. The other thoughts I have involve testing the drive using the File System Object, or using a registry setting or ini file. These can all make you application more dynamic. You can read more about the File System Object in the MDSN files - On line help.

Hope this helps.

Larry Asher
Old November 3rd, 2003, 12:50 PM
Registered User
Join Date: Nov 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

It seems to work great!!!
Thank you very much, Larry:):):)

Similar Threads
Thread Thread Starter Forum Replies Last Post
code to read two text files, concatenate one...... dgr7 Beginning VB 6 2 April 18th, 2007 03:24 PM
open access db from read only media (eg. CD) albertos ADO.NET 0 August 27th, 2005 06:54 PM
Install with no auto CD read gsmitchell Linux 1 October 22nd, 2004 09:34 AM
CD-R and CD -RW info wwwdirzala Beginning VB 6 0 May 4th, 2004 04:00 AM
How to read multiple text files into excel? Together Excel VBA 4 March 5th, 2004 06:26 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.