Click to See Complete Forum and Search --> : open+read+write to file in public folders
mgeerkens
Dec 7th, 2000, 09:49 AM
I have to access a file located in the public folders.
How can i do this in the easieest way? The path is always the same (it is in an outlook form). First i have to read from it, then i have to write to it. Can i eventually also use read only rights while editing it, so that when others try to write to it, when another one is writing to it, that that won't work?
Thanx 4 helping me.
[Edited by mgeerkens on 12-08-2000 at 02:24 AM]
Ianpbaker
Dec 7th, 2000, 10:38 AM
what type of file is it, and are you trying to this in ASP ?
Ian
mgeerkens
Dec 8th, 2000, 01:25 AM
I am not trying this in ASP, just in VBscript from the form.
It is a small txt-file with 2 numbers in it one is a counter which has to be increased.
Thanx again
Ianpbaker
Dec 8th, 2000, 03:11 AM
all you need is the following code
<script language="VBSCRIPT">
Sub OpenTextFileTest
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
f.Write "Hello world!"
f.Close
End Sub
</SCRIPT>
the above code will open a file on the clients machine
if you want to open a file on the server use the following
<script language="VBSCRIPT" RUNAT="SERVER">
Sub OpenTextFileTest
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
f.Write "Hello world!"
f.Close
End Sub
</SCRIPT>
if that doesn't work, then i think you need to do it in asp
hope this helps
Ian
mgeerkens
Dec 8th, 2000, 03:26 AM
Could you tell me someting more about
ASP?
And i know how to do that on a local machine, but if i have to open the file from the public folders, so there is no c:\dirname in it....
Thanx again!!
Ianpbaker
Dec 8th, 2000, 03:37 AM
ASP - or active server pages is a way of dynamically creating pages on the fly and all the code that writes it is normally in vbscript. all the pages are created on the server and the client see's the end result. where you say the files are in public folders, do you meen their on virtual directories on the web server or on public folders on a network domain
mgeerkens
Dec 8th, 2000, 03:52 AM
it is a public folder on the Server. It is not a web server, so i think it is the one on the network domain.
If you are browsing in the public folders and you ask the properties of the folder where the file is in you can see the location like : \firstsubdir\secondsubdir\knowledgebase
Thanx again
Ianpbaker
Dec 8th, 2000, 03:56 AM
in that case give this a go
<script language="VBSCRIPT" RUNAT="SERVER">
Sub OpenTextFileTest
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("\\servername\firstsubdir\secondsubdir\knowledgebase\filename", ForWriting, True)
f.Write "Hello world!"
f.Close
End Sub
</SCRIPT>
as you can use relative path's in the opentextfile function
if that doesn't work then you will need to go down the asp route, but if you don't know anything about asp, I can;t really explain how to do it
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.