opening files

I wrote a program that uses info from a text file. When I tried to copy and run from the A drive it can't find the text file, so I have to change the code a little. What I was wondering, was if there is a way to code it that will work from the C drive or the A drive. Here's the code for the C drive to be able to find the file.

Open App.Path & "\IntTest.txt" For Input As #2

In order for it to work with the A drive I had to change it to this.

Open App.Path & "IntTest.txt" For Input As #2

Well, any ideas??
seeshelleAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

trilloCommented:
Well your code (the one for the C:\ drive) will only work if the App.Path is not the root.
If you're working on your hard drive's root, App.Path will return C:\ (with the slash) and your could would be just te same as with de floppy drive.

I always use a function to avoid problems:

Public Function GetSlashedPath(sPath As String) As String
    If Len(sPath) = 0 Then
        GetSlashedPath = "\"
    ElseIf Mid(sPath, Len(sPath), 1) = "\" Then
        GetSlashedPath = sPath
    Else
        GetSlashedPath = sPath & "\"
    End If
End Function

This will always return a path with the trailing slash

The you could call
Open GetSlashedPath(App.Path) & "IntTest.txt" For Input As #2
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
seeshelleAuthor Commented:
I'll give it a try!! thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.