|
-
Dec 12th, 2002, 11:24 AM
#1
Thread Starter
Addicted Member
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.
-
Dec 12th, 2002, 11:29 AM
#2
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)
-
Dec 13th, 2002, 04:01 AM
#3
Thread Starter
Addicted Member
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 ?
-
Dec 13th, 2002, 11:20 AM
#4
Frenzied Member
When opening a file, there s no password setting. However, when mapping a drive you can do:
Map:
VB Code:
Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
Private Sub Form_Load()
WNetAddConnection "\\vdk00005\proj", "", "H:"
End Sub
UnMap:
VB Code:
Private Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long
Private DisconnectIt As Long
'Where H: is the drive letter you wish to dis-connect
'The second parameter of this API determines whether to disconnect
‘ the drive if there are files open on it.
‘ If it is passed FALSE, the disconnect will fail if there are open files
'If it is passed TRUE, the disconnect will occur no matter
‘ what is open on the drive
DisconnectIt = WNetCancelConnection("H:", True)
-
Dec 13th, 2002, 11:23 AM
#5
Retired VBF Adm1nistrator
You could always just try this
VB Code:
Open "\\10.10.10.10\Test\listing\acme\guess\testtext.txt" For Binary As #1
Dim strBuff As String: strBuff = Space(Lof(1))
Get #1, , strBuff
'' strBuff should contain contents of file
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|