VB6 file handling  
Author Message
acrowl





PostPosted: Tue Jan 30 11:04:59 CST 2007 Top

Visual Basic >> VB6 file handling

Forgive the newbie question, but I have a small program (in VB6) which
writes data to a file, which by default is in the folder in which the
program resides. I know that this is not appropriate as the permissions for
anyone who is not an administrator will not allow this. What I have been
trying to find out is how to use the current users "My Documents" folder and
"Local Settings > Temp" folder. I know that there must be a wildcard or
some other easy way to automatically direct file writing to these folders
but for some reason I have been unable to figure it out or find anything
about it (probably hidden in plain sight). If someone could point me in the
right direction I would appreciate it.

Thank you,
Brian

Visual Studio71  
 
 
Ken





PostPosted: Tue Jan 30 11:04:59 CST 2007 Top

Visual Basic >> VB6 file handling

> Forgive the newbie question, but I have a small program (in VB6) which
> writes data to a file, which by default is in the folder in which the
> program resides. I know that this is not appropriate as the permissions
> for anyone who is not an administrator will not allow this. What I have
> been trying to find out is how to use the current users "My Documents"
> folder and "Local Settings > Temp" folder. I know that there must be a
> wildcard or some other easy way to automatically direct file writing to
> these folders but for some reason I have been unable to figure it out or
> find anything about it (probably hidden in plain sight). If someone could
> point me in the right direction I would appreciate it.
>
> Thank you,
> Brian

These may come in handy...

Retrieve Windows Shell Folders (Best Practice)
http://vbnet.mvps.org/code/browse/csidl.htm

GetTempFileName: Create Temporary Files for Application Use
http://vbnet.mvps.org/code/fileapi/gettempfilename.htm


--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm


 
 
Brian





PostPosted: Tue Jan 30 11:34:30 CST 2007 Top

Visual Basic >> VB6 file handling Thanks for the info Ken. This is most definitely helpful.

Brian






>> Forgive the newbie question, but I have a small program (in VB6) which
>> writes data to a file, which by default is in the folder in which the
>> program resides. I know that this is not appropriate as the permissions
>> for anyone who is not an administrator will not allow this. What I have
>> been trying to find out is how to use the current users "My Documents"
>> folder and "Local Settings > Temp" folder. I know that there must be a
>> wildcard or some other easy way to automatically direct file writing to
>> these folders but for some reason I have been unable to figure it out or
>> find anything about it (probably hidden in plain sight). If someone
>> could point me in the right direction I would appreciate it.
>>
>> Thank you,
>> Brian
>
> These may come in handy...
>
> Retrieve Windows Shell Folders (Best Practice)
> http://vbnet.mvps.org/code/browse/csidl.htm
>
> GetTempFileName: Create Temporary Files for Application Use
> http://vbnet.mvps.org/code/fileapi/gettempfilename.htm
>
>
> --
> Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
> In Loving Memory - http://www.vbsight.com/Remembrance.htm
>


 
 
Larry





PostPosted: Tue Jan 30 12:26:10 CST 2007 Top

Visual Basic >> VB6 file handling


> > folder and "Local Settings > Temp" folder. I know that there must be a
> > wildcard or some other easy way to automatically direct file writing to
> > these folders but for some reason I have been unable to figure it out or
> > find anything about it (probably hidden in plain sight). If someone could
> > point me in the right direction I would appreciate it.
>
> These may come in handy...
>
> Retrieve Windows Shell Folders (Best Practice)
> http://vbnet.mvps.org/code/browse/csidl.htm
>
> GetTempFileName: Create Temporary Files for Application Use
> http://vbnet.mvps.org/code/fileapi/gettempfilename.htm


I wonder which systems this would work for ???

MsgBox Environ("APPDATA")

;-)
LFS


 
 
Karl





PostPosted: Tue Jan 30 13:57:30 CST 2007 Top

Visual Basic >> VB6 file handling

>
>>> folder and "Local Settings > Temp" folder. I know that there must be a
>>> wildcard or some other easy way to automatically direct file writing to
>>> these folders but for some reason I have been unable to figure it out or
>>> find anything about it (probably hidden in plain sight). If someone could
>>> point me in the right direction I would appreciate it.
>>
>> These may come in handy...
>>
>> Retrieve Windows Shell Folders (Best Practice)
>> http://vbnet.mvps.org/code/browse/csidl.htm
>>
>> GetTempFileName: Create Temporary Files for Application Use
>> http://vbnet.mvps.org/code/fileapi/gettempfilename.htm
>
>
> I wonder which systems this would work for ???
>
> MsgBox Environ("APPDATA")
>
> ;-)

None that I'm aware of...

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>set appdata
APPDATA=C:\Documents and Settings\karl\Application Data

C:\>set appdata=Bite me

C:\>set appdata
APPDATA=Bite me

C:\>set appdata=C:\Documents and Settings\karl\Application Data

C:\>set appdata
APPDATA=C:\Documents and Settings\karl\Application Data

C:\>

Okay, extreme example, sure. But the point is, the system *provides* a mechanism
for this, and taking the shortcut isn't necessarily the smartest path. (Reminds me
of a guy named James Kim.)


Fwiw...
--
.NET: It's About Trust!
http://vfred.mvps.org


 
 
Larry





PostPosted: Tue Jan 30 18:01:58 CST 2007 Top

Visual Basic >> VB6 file handling


> > I wonder which systems this would work for ???
> >
> > MsgBox Environ("APPDATA")
> >
>
> None that I'm aware of...
>
>
> C:\>set appdata=Bite me

If that is where you want your data to reside, then so be it.

Specifically the OP asked for the user's temp folder:

"What I have been trying to find out is how to use the current users
"My Documents" folder and "Local Settings > Temp" folder. "

That's the folder you'd get from Environ("TEMP").
What's the CSIDL for that one?

FWIW
LFS


 
 
Karl





PostPosted: Tue Jan 30 18:43:34 CST 2007 Top

Visual Basic >> VB6 file handling

>
>>> I wonder which systems this would work for ???
>>>
>>> MsgBox Environ("APPDATA")
>>>
>>
>> None that I'm aware of...
>>
>>
>> C:\>set appdata=Bite me
>
> If that is where you want your data to reside, then so be it.

Has nothing to do with me. Why do you want to make it personal?

> Specifically the OP asked for the user's temp folder:
>
> "What I have been trying to find out is how to use the current users
> "My Documents" folder and "Local Settings > Temp" folder. "
>
> That's the folder you'd get from Environ("TEMP").
> What's the CSIDL for that one?

That hasn't changed since Win 1.0: GetTempPath(MAX_PATH, Buffer) -- HTH!
--
.NET: It's About Trust!
http://vfred.mvps.org