Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Calling documents from users harddrive

Posted on 2001-06-11
5
Medium Priority
?
194 Views
Last Modified: 2010-05-02
Ok,

I need to be able to access several templates in this program.  Currently I call them from "C:/documentlocation".

However, when I package this program, not sure where the documents will be installed (for example, the user may wish to have the program installed on his D: drive).  Is there an easy way to either:
a.  Set location of install at packaging time, so that I can ensure that my templates install to "C:/documentlocation" on the user computer

or, and perhaps better,

b.  Determine where the templates are located on the machine when the program is run, so that the program picks the proper template (and I avoid thoes awful errors)

thanks

(sorry bout low points, but almost out and still got a few ? left to finish the project)
0
Comment
Question by:phred_the_cat
5 Comments
 
LVL 3

Expert Comment

by:jrspano
ID: 6178065
let the user find them the first time and then save off the dir they picked in the registry and look there next time.
0
 
LVL 1

Accepted Solution

by:
ShaneCourtrille earned 200 total points
ID: 6178201
Why not just have them installed by default into a sub directory of your application?

MyApp\Templates

Then you can always be assured that (unless the user has messed up the install) the templates are in the following location:

App.Path & "\Templates"

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6178269
I am with ShaneCourtrille.
jrspano, i would with you too, but i dodn't trust on end-users and we could get some more calls to support service.
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 6178273
here is some code to locate a file...what you can do is put a file name "TEMPLATES.923" or something with them and run this code to get the full path of where the templates are...

us it like this: MsgBox FindFile("c:\", "templates.txt")

GOOD LUCK :)


''''''''''

Declare Function SearchTreeForFile Lib "IMAGEHLP.DLL" _
    (ByVal lpRootPath As String, _
    ByVal lpInputName As String, _
    ByVal lpOutputName As String) As Long
   
Public Const MAX_PATH = 260

Public Function FindFile(RootPath As String, _
    FileName As String) As String
   
    Dim lNullPos As Long
    Dim lResult As Long
    Dim sBuffer As String
   
    On Error GoTo FileFind_Error
   
    'Allocate buffer
    sBuffer = Space(MAX_PATH * 2)
   
    'Find the file
    lResult = SearchTreeForFile(RootPath, FileName, sBuffer)
   
    'Trim null, if exists
    If lResult Then
        lNullPos = InStr(sBuffer, vbNullChar)
        If Not lNullPos Then
            sBuffer = Left(sBuffer, lNullPos - 1)
        End If
        'Return filename
        FindFile = sBuffer
    Else
        'Nothing found
        FindFile = vbNullString
    End If
   
    Exit Function
   
FileFind_Error:
    FindFile = vbNullString
   
End Function
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6179889
Hi!

Here's a file for you over the net.  Simply set the filename or extention (ie. *.tmp) to find out where the files are.

For interest sake, this one scans every and will list every file with the string that you want.  You'll have to know what same string exists in all your template files : )

Download...
http://www.vb-helper.com/Howto/findstr.zip
Description: Search files matching a pattern below a directory for a string (5K)

Thios one lists out all files matching a pattern.

Download...
http://www.vb-helper.com/Howto/search2.zip
Descrition: Search for files matching a pattern and show their total size (3K)

Well, you may want to merg the 2 in case there are 2 folders with different templates (from different programs) but using the same extention.

That's it!

glass cookie : )
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Suggested Courses

926 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