Path of data file in same directory as .exe
Path of data file in same directory as .exe
Path of data file in same directory as .exe
Path of data file in same directory as .exe
Path of data file in same directory as .exe
Path of data file in same directory as .exe Path of data file in same directory as .exe Path of data file in same directory as .exe Path of data file in same directory as .exe Path of data file in same directory as .exe Path of data file in same directory as .exe Path of data file in same directory as .exe Path of data file in same directory as .exe
Path of data file in same directory as .exe Path of data file in same directory as .exe
Path of data file in same directory as .exe
Go Back  Xtreme Visual Basic Talk > > > Path of data file in same directory as .exe


Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2016, 08:16 PM
leezinho leezinho is offline
Freshman
 
Join Date: Jun 2009
Posts: 45
Default Path of data file in same directory as .exe


During development, I have told my program where to find its data by specifying the full path (C:\...) to where the data file is located on my computer. But when the program is exported to other computers, the data file will be located in the same folder with the .exe file of the program, and I need a generic expression for the path which will work on other computers, without my knowing what name users will give to the folder where they locate the program and data file. I have tried saying simply "Open [filename.extension] for Input As 1", assuming it will be understood that without the Drive and Directory specifications the default will be the directory where the program is located. But this approach gets me the message "Error 76: Path Not Found". This is hard to debug, because it happens only on someone else's compter, running the .exe file. Is there a way to designate a data file in the same folder generically? Or do I have to tell users what path and directory name they have to put the program and data in? I have not found an answer in the 642 pages of Programmer’s Guide VB 5.0.
Reply With Quote
  #2  
Old 09-19-2016, 02:25 AM
Flyguy's Avatar
FlyguyPath of data file in same directory as .exe Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,145
Default

App.Path will return the path in which your EXE resides.
Reply With Quote
  #3  
Old 09-20-2016, 08:47 AM
leezinho leezinho is offline
Freshman
 
Join Date: Jun 2009
Posts: 45
Default Thanks!!

Thank you, Flyguy! I have a lot riding on whether this program can be shared, and you have helped me with some crucial steps. I deeply appreciate it.
"App.Path": so simple, yet so cryptic!
Reply With Quote
  #4  
Old 09-20-2016, 08:59 AM
PlausiblyDamp's Avatar
PlausiblyDampPath of data file in same directory as .exe PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,056
Default

You need to be careful where the app is deployed to if you are using App.Path to store files, if your app is going to be deployed under Program Files then a normal user will not have write permissions.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #5  
Old 09-20-2016, 05:25 PM
dilettante's Avatar
dilettantePath of data file in same directory as .exe dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,517
Default

When a program is using a relative path to a file it is relative to the current directory. That is only the same as App.Path when you get lucky: they can easily be entirely different things.

I agree, App.Path is not the proper place to put any data files unless they are read-only. You can get away with that for throwaway programs dumped into any random full access part of the filesystem, but it fails for properly installed programs.

If you leave your programs as "legacy" then appcompat usually bypasses the security violation by applying filesystem virtualization. But you don't really want either of those things to occur. The cleanest thing is to use a "Vista aware" manifest and put data files in the proper folders.

Ultimately that's more of a deployment question than a programming question, but the code needs to look in the right place too.
Reply With Quote
  #6  
Old 09-21-2016, 11:12 AM
leezinho leezinho is offline
Freshman
 
Join Date: Jun 2009
Posts: 45
Default

I take back my comment "So simple!" and leave it at "So cryptic!"
Reply With Quote
Reply

Tags
file, data, program, path, directory, located, .exe, folder, found, computers, users, compter, debug, elses, message, error, running, hard, pages, answer, programmer’s, guide, designate, generically, approach


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Path of data file in same directory as .exe
Path of data file in same directory as .exe
Path of data file in same directory as .exe Path of data file in same directory as .exe
Path of data file in same directory as .exe
Path of data file in same directory as .exe
Path of data file in same directory as .exe Path of data file in same directory as .exe Path of data file in same directory as .exe Path of data file in same directory as .exe Path of data file in same directory as .exe Path of data file in same directory as .exe Path of data file in same directory as .exe
Path of data file in same directory as .exe
Path of data file in same directory as .exe
 
Path of data file in same directory as .exe
Path of data file in same directory as .exe
 
-->