Solved

Calling documents from users harddrive

Posted on 2001-06-11
5
186 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

947 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now