Results 1 to 5 of 5

Thread: Opening file over local network

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    South West UK
    Posts
    245

    Opening file over local network

    I am running on a company network NT system and i am looking for my application to be stored on the users area of the network but i need the reference files to be stored on another area of the network (not accessable to the user through Explorer). Does anyone have a code snippet of how to reference files accross a network???

    example:

    need app to open up and read text files from....

    Ip address = 10.10.10.10

    Root of file = Test/listing/acme/guess

    File name = testtext.txt

    Any help really appreciated.
    A lowly programmer.

    http://www.sentinalgroup.com

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Opening file over local network

    Originally posted by HELPmyVB
    I am running on a company network NT system and i am looking for my application to be stored on the users area of the network but i need the reference files to be stored on another area of the network (not accessable to the user through Explorer). Does anyone have a code snippet of how to reference files accross a network???

    example:

    need app to open up and read text files from....

    Ip address = 10.10.10.10

    Root of file = Test/listing/acme/guess

    File name = testtext.txt

    Any help really appreciated.
    if the drive is on the network you can access it using its name... but the user must have access to the drive..

    the only reason it doesn't show in explorer is because it is not mapped.. but if they have access they should still be able to access it by typing its path.. so you could do the same in code..

    for example

    //COMPUTERNAME/Test/listing/acme/guess

    should bring you to that path if it is on the network and you have permissions and the drive is shared (or no permission restrictions have been set on the share)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    South West UK
    Posts
    245
    Yeah, i have tried that method, but as yet still no luck. Is there a format to passing parameters, eg password etc, if the user does not normally have permissions ?
    A lowly programmer.

    http://www.sentinalgroup.com

  4. #4
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    When opening a file, there s no password setting. However, when mapping a drive you can do:

    Map:
    VB Code:
    1. Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
    2.  
    3. Private Sub Form_Load()
    4. WNetAddConnection "\\vdk00005\proj", "", "H:"
    5. End Sub
    UnMap:
    VB Code:
    1. Private Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long
    2. Private DisconnectIt As Long
    3.  
    4. 'Where H: is the drive letter you wish to dis-connect
    5. 'The second parameter of this API determines whether to disconnect
    6. ‘ the drive if there are files open on it.  
    7. ‘ If it is passed FALSE, the disconnect will fail if there are open files
    8. 'If it is passed TRUE, the disconnect will occur no matter
    9. ‘   what is open on the drive
    10. DisconnectIt = WNetCancelConnection("H:", True)

  5. #5
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    You could always just try this

    VB Code:
    1. Open "\\10.10.10.10\Test\listing\acme\guess\testtext.txt" For Binary As #1
    2.     Dim strBuff As String: strBuff = Space(Lof(1))
    3.     Get #1, , strBuff
    4.     '' strBuff should contain contents of file
    5. Close #1



    Also try doing :
    Start > Run > \\10.10.10.10\Test\listing\acme\guess\testtext.txt

    To make sure that you can browse to it.

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