Solved

OPEN File with app.Path fails when application is installed on server

Posted on 2003-10-28
4
149 Views
Last Modified: 2010-05-01
I try to read an ascii file with the

Open filelocation for Input as #1

the file is located were the application is located. In this case it is located were my VB project file is located.
I am working from as server so it is located on the server.

In order to get the exact pathway I get the filelocation by calling

filelocation = App.Path & "File"

This then looks like:
 filelocation  = "//SERVERNAME\Research\VB-programme\hran\eval\master\test.cnf"

When I call
Open filelocation for Input as #1
it then comes up with the error message:
[Run Time Error 53  File not found]

I then tried to assign filelocation with the path it is showing in the EXPLORER task bar. Because the Server drive is mapped it comes up with the following:
"X:\Research\VB-programme\hran\eval\master\test.cnf"

Whe I then assign:
filelocation ="X:\Research\VB-programme\hran\eval\master\test.cnf"

all works fine and the programme finds the file.

How can I find the file by using the App.Path comand???? Because I need to use this command !
0
Comment
Question by:themroc
4 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 180 total points
ID: 9632775
App.Path is not finished by "\". Try

App.Path & "\" & ...
0
 
LVL 13

Assisted Solution

by:crazyman
crazyman earned 30 total points
ID: 9632877
This is also bad...

Open filelocation for Input as #1

should be

dim lFile as long
lFile = freefile
Open filelocation for Input as #lFile
0
 

Author Comment

by:themroc
ID: 9632937
thanks AlexFM, I was sure I tried it before but apparently I did not, because it works fine now.
thankd a lot.
Also some Points for crazyman, why is writing #1 so bad, I imagine it canbe that it can cause conflicts with other open files and freefile does only assign exactly the number which is available.

Would be nice if you could comment on this


:)
themroc
0
 
LVL 1

Expert Comment

by:mahesh_mp
ID: 9632957
hello  themroc

i think you are modifiying your app.path

because your path cannot have back slesh "//" it should be fornt slesh "\\"

your file location
filelocation  = "//SERVERNAME\Research\VB-programme\hran\eval\master\test.cnf"

this can work
filelocation  = "\\SERVERNAME\Research\VB-programme\hran\eval\master\test.cnf"



0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question