|
|
VBScript and FileSystemObject |
|
Author |
Message |
RvV

|
Posted: Mon May 07 19:05:53 CDT 2007 |
Top |
VB Scripts >> VBScript and FileSystemObject
I have a website that allows FileSystemObject to be used on files on the
website itself. But when I use WriteLine to try and add to the file,
nothing happens and the file has not been changed. It works when I have it
modify the file on my hard drive, but when I try to have it modify the one
on the website, it doesn't work.
The two files, one called test.htm, and the one with the code that modifies
test.htm, are both in the same folder. This is the code I use to open the
file - I think this is where the problem is occuring...
dim fso, thefile
Set fso = CreateObject("Scripting.FileSystemObject")
Set thefile = fso.OpenTextFile("test.htm", 8, False)
Is there something I need to add in front of the "test.htm" to get it to
look on the website itself instead of on the user's hard drive?
Thanks!
Visual Studio378
|
|
|
|
 |
Michael

|
Posted: Mon May 07 19:05:53 CDT 2007 |
Top |
VB Scripts >> VBScript and FileSystemObject
> I have a website that allows FileSystemObject to be used on files on
> the website itself. But when I use WriteLine to try and add to the
> file, nothing happens and the file has not been changed. It works
> when I have it modify the file on my hard drive, but when I try to
> have it modify the one on the website, it doesn't work.
>
> The two files, one called test.htm, and the one with the code that
> modifies test.htm, are both in the same folder. This is the code I
> use to open the file - I think this is where the problem is
> occuring...
> dim fso, thefile
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set thefile = fso.OpenTextFile("test.htm", 8, False)
>
> Is there something I need to add in front of the "test.htm" to get it
> to look on the website itself instead of on the user's hard drive?
Yes...
...if this is (allowed) client side (browser) code then an accessible UNC
path to the file on the server would certainly help.
...if this is server side (asp) code, Server.MapPath(".\test.htm") will
provide the full server side local path.
--
Michael Harris
Microsoft.MVP.Scripting
|
|
|
|
 |
Mike

|
Posted: Mon May 07 19:09:03 CDT 2007 |
Top |
VB Scripts >> VBScript and FileSystemObject
>> Is there something I need to add in front of the "test.htm" to get it
>> to look on the website itself instead of on the user's hard drive?
>
> Yes...
>
> ...if this is (allowed) client side (browser) code then an accessible UNC
> path to the file on the server would certainly help.
Sorry, I'm new at this... What's a UNC path?
|
|
|
|
 |
Mike

|
Posted: Mon May 07 20:00:12 CDT 2007 |
Top |
VB Scripts >> VBScript and FileSystemObject
> Sorry, I'm new at this... What's a UNC path?
OK, I just did a search and found out what a UNC path is... But I'm still
not sure what the UNC path for my site is. I've tried various combinations,
such as:
\\mysitename\wwwroot\myfolder\file.htm
\\wwwroot\myfolder\file.htm
but none have worked.
Any suggestions?
Thanks!
|
|
|
|
 |
Anthony

|
Posted: Tue May 08 04:59:39 CDT 2007 |
Top |
VB Scripts >> VBScript and FileSystemObject
> I have a website that allows FileSystemObject to be used on files on the
> website itself. But when I use WriteLine to try and add to the file,
> nothing happens and the file has not been changed. It works when I have
it
> modify the file on my hard drive, but when I try to have it modify the one
> on the website, it doesn't work.
>
> The two files, one called test.htm, and the one with the code that
modifies
> test.htm, are both in the same folder. This is the code I use to open the
> file - I think this is where the problem is occuring...
>
> dim fso, thefile
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set thefile = fso.OpenTextFile("test.htm", 8, False)
>
> Is there something I need to add in front of the "test.htm" to get it to
> look on the website itself instead of on the user's hard drive?
>
> Thanks!
>
Try this:-
Set thefile = fso.OpenTextFile(Server.MapPath("test.htm"), 8, False)
|
|
|
|
 |
Mike

|
Posted: Tue May 08 11:26:49 CDT 2007 |
Top |
VB Scripts >> VBScript and FileSystemObject
> Try this:-
>
> Set thefile = fso.OpenTextFile(Server.MapPath("test.htm"), 8, False)
I tried that, but it didn't work... I even tried using an ASP file to store
the code instead of an HTML file, but that didn't work either.
|
|
|
|
 |
|
|