Results 1 to 8 of 8

Thread: open+read+write to file in public folders

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Posts
    4

    Unhappy

    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]

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    what type of file is it, and are you trying to this in ASP ?

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Posts
    4

    Unhappy

    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

  4. #4
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    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








    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Posts
    4
    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!!

  6. #6
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    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
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  7. #7

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Posts
    4
    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

  8. #8
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    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

    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width