Hi Guys,

How do I export a file to a user's desktop, given I don't want to hardcode the
path into my program.

I can do this on Win98 easily:

EXPORT TO c:\windows\desktop\aodbal.xls TYPE xls

But I have a mixed network of unix, 98, XP and 2003 server machines, so how do I
do this on a variety of platforms? (ignore unix <g>)

I think I spent to long working on Unix and have definitely got left behind a bit!!

Steve

Re: Saving a file to a users desktop. by Eric

Eric
Wed Nov 24 05:57:09 CST 2004

Hello, Steve!
<vfp_code>
o=NEWOBJECT("_commonfolder", HOME() + "ffc\_system.vcx")
?o.getfolder(0x0010)
</vfp_code>

More path constants:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8



Re: Saving a file to a users desktop. by Steve

Steve
Wed Nov 24 07:53:58 CST 2004

> <vfp_code>
> o=NEWOBJECT("_commonfolder", HOME() + "ffc\_system.vcx")
> ?o.getfolder(0x0010)
> </vfp_code>

Hi Eric,

Been playing with the above code - Do I use like this? (which works):

o=NEWOBJECT("_commonfolder", HOME() + "ffc\_system.vcx")
Fname=o.getfolder(0x0010)

Fname=Fname+"\"+"aodbals.xls"

Or is there a better way to do it??

Steve.

Re: Saving a file to a users desktop. by Eric

Eric
Wed Nov 24 08:23:43 CST 2004

Hello, Steve!
You wrote on Wed, 24 Nov 2004 13:53:58 +0000 (UTC):

??>> <vfp_code>
??>> o=NEWOBJECT("_commonfolder", HOME() + "ffc\_system.vcx")
??>> ?o.getfolder(0x0010)
??>> </vfp_code>

SF> Hi Eric,

SF> Been playing with the above code - Do I use like this? (which works):

SF> o=NEWOBJECT("_commonfolder", HOME() + "ffc\_system.vcx")
SF> Fname=o.getfolder(0x0010)

SF> Fname=Fname+"\"+"aodbals.xls"

SF> Or is there a better way to do it??

That's OK but you can do the same with a single line:

Fname=ADDBS(Fname=o.getfolder(0x0010)) + [aodbals.xls]
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8



Re: Saving a file to a users desktop. by Sietse

Sietse
Wed Nov 24 08:55:49 CST 2004

Hi Steve,

> Fname=Fname+"\"+"aodbals.xls"

Take a look at the ADDBS() function. If the folder already contains a
backslash at the end you'll get something like
c:...\foldername\\aodbals.xls
with the ADDBS() that wouldn't occur. it only adds a backslash when it's not
there.

Furthermore, i would use a header file or DEFINE's for readablity of your
code. When you look at your code six months from now you might know that it
returs a file-path onto the desktop, but then again you might not:

#DEFINE CSIDL_DESKTOPDIRECTORY 0x0010

o=NEWOBJECT("_commonfolder", HOME() + "ffc\_system.vcx")
Fname = ADDBS(o.getfolder(CSIDL_DESKTOPDIRECTORY)) + "aodbals.xls"

For more values you can pass to the GetFolder method:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp

> I can do this on Win98 easily:
> EXPORT TO c:\windows\desktop\aodbal.xls TYPE xls
You might want to use the GETENV() function to retrieve the path to the
windows folder. What if windows is installed on the D drive?
EXPORT TO (ADDBS(GETENV('windir')) + 'desktop\aodbal.xls' TYPE xls

BTW, the requirements to use the GetFolder method in the _system.vcx (using
the SHGetFolderPath() API call):
Minimum operating systems Windows 95 with Internet Explorer 5.0,
Windows 98 with Internet Explorer 5.0, Windows 98 Second Edition (SE),
Windows NT 4.0 with Internet Explorer 5.0, Windows NT 4.0 with Service Pack
4 (SP4)


Regards,
Sietse Wijnker



Re: Saving a file to a users desktop. by borisb

borisb
Fri Nov 26 02:46:33 CST 2004

Sietse,
no true abaout ADDBS (at least in VFP8)
no metter if the path end or not end with backslash the function always
retirns the path with one backslash at the end.
Boris

Sietse Wijnker wrote:
> Hi Steve,
>
>
>>Fname=Fname+"\"+"aodbals.xls"
>
>
> Take a look at the ADDBS() function. If the folder already contains a
> backslash at the end you'll get something like
> c:...\foldername\\aodbals.xls
> with the ADDBS() that wouldn't occur. it only adds a backslash when it's not
> there.
>
> Furthermore, i would use a header file or DEFINE's for readablity of your
> code. When you look at your code six months from now you might know that it
> returs a file-path onto the desktop, but then again you might not:
>
> #DEFINE CSIDL_DESKTOPDIRECTORY 0x0010
>
> o=NEWOBJECT("_commonfolder", HOME() + "ffc\_system.vcx")
> Fname = ADDBS(o.getfolder(CSIDL_DESKTOPDIRECTORY)) + "aodbals.xls"
>
> For more values you can pass to the GetFolder method:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp
>
>
>>I can do this on Win98 easily:
>>EXPORT TO c:\windows\desktop\aodbal.xls TYPE xls
>
> You might want to use the GETENV() function to retrieve the path to the
> windows folder. What if windows is installed on the D drive?
> EXPORT TO (ADDBS(GETENV('windir')) + 'desktop\aodbal.xls' TYPE xls
>
> BTW, the requirements to use the GetFolder method in the _system.vcx (using
> the SHGetFolderPath() API call):
> Minimum operating systems Windows 95 with Internet Explorer 5.0,
> Windows 98 with Internet Explorer 5.0, Windows 98 Second Edition (SE),
> Windows NT 4.0 with Internet Explorer 5.0, Windows NT 4.0 with Service Pack
> 4 (SP4)
>
>
> Regards,
> Sietse Wijnker
>
>

Re: Saving a file to a users desktop. by Sietse

Sietse
Fri Nov 26 03:47:18 CST 2004

Hi Boris,

"borisb" <borisb@mail.bg> wrote in message
news:ObkyuR50EHA.3840@tk2msftngp13.phx.gbl...
> no true abaout ADDBS (at least in VFP8)
> no metter if the path end or not end with backslash the function always
> retirns the path with one backslash at the end.
> Boris

Maybe my typing wasn't that clear, but that's exactly what i said (or at
least ment).
<current situation referal>
>> Take a look at the ADDBS() function. If the folder already contains a
>> backslash at the end you'll get something like
>> c:...\foldername\\aodbals.xls
</current situation referal>
<emphasise>
>> with the ADDBS() that wouldn't occur. it only adds a backslash when it's
>> not there.
</emphasise>

<rest snipped>

Regards,
Sietse Wijnker