Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

Connection to a folder in a server to move files to it.

I am attempting to write a program tnd have it connect to a server and copy some files into that folder.

Example:
Server Name is ServerA
Target Folder is FolderB in drive D:\ which is shared

I would like to connect to FolderB in ServerA (ie. "\\ServerA\FolderB) before I start copying the relevant files into the folder. Is there a way for me to hardcode the userID and password in the program? I am currently using fso (filesystemobject) to run the copy but hit an error ("Path not found") if I am not connected to the server. Thank you.


0
kacang
Asked:
kacang
  • 6
  • 3
  • 3
1 Solution
 
priya_pbkCommented:
Try using the "Inet" control for uploading the files from your server (ie server A) to a different server(server b)

Yes, you gotto mention the username and password before uploading it. I think Inet control is one of the good ways in which one can upload files.

-priya




0
 
TimCotteeHead of Software ServicesCommented:
http://www.mvps.org/vbnet/code/network/netconnect.htm

May help in demonstrating how to make a connection to a network resource.
0
 
priya_pbkCommented:
You can try this way:
--------------------------------------
Place a Inet1 control on your form

Private Sub Command1_click()

With Inet1
     .Cancel
     .Protocol = icFTP
     .URL = "xyz.com"
     .UserName = clientUserName
     .Password = clientPassword
End With

localFile="c:\test.htm"
webfile="\\ServerA\FolderB\test.htm" 'it will overwrite if the file exists

Inet1.Execute , "PUT " & localfile & " " & webfile

      Do While Inet1.StillExecuting
         DoEvents
      Loop

     If Inet1.ResponseCode <> 0 Then
             msgbox Inet1.ResponseInfo     'Some error
     End if

End Sub
----------------------------------------------

I think the file name should be mentioned, for uploading.


I hope this helps!

-priya

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
kacangAuthor Commented:
priya_pbk,
thanx 4 ur suggestion :) however, i am trying to avoid using the ftp protocol as i hit a number of files lost in transfer. currently, my program does the file porting via ftp and i am transfering between 1,000 to 3,000 files. i hit an average of 100 to 200 file loses in the process. that's why i am reverting to a normal copy method (using fso to file.copy(destination & filename) but i need to connect first, hence this problem) as i do not think i would lose any files this way.

TimCottee,
thanx for the suggested site, i hope it is not another ftp methiod. i haven't check it out yet but will be looking into it immediately. will give more feedback afterds, ok?
0
 
TimCotteeHead of Software ServicesCommented:
No, this is about programatically creating a connection to a network resource on a server on a LAN/WAN. You can then use normal file-copy methods such as FSO if you must, though I would prefer API methods as they tend to be faster and you can use the standard visible representation as if you were dragging/dropping using explorer.
0
 
kacangAuthor Commented:
priya_pbk,
thanx 4 ur suggestion :) however, i am trying to avoid using the ftp protocol as i hit a number of files lost in transfer. currently, my program does the file porting via ftp and i am transfering between 1,000 to 3,000 files. i hit an average of 100 to 200 file loses in the process. that's why i am reverting to a normal copy method (using fso to file.copy(destination & filename) but i need to connect first, hence this problem) as i do not think i would lose any files this way.

TimCottee,
thanx for the suggested site, i hope it is not another ftp methiod. i haven't check it out yet but will be looking into it immediately. will give more feedback afterds, ok?
0
 
kacangAuthor Commented:
priya_pbk,
thanx 4 ur suggestion :) however, i am trying to avoid using the ftp protocol as i hit a number of files lost in transfer. currently, my program does the file porting via ftp and i am transfering between 1,000 to 3,000 files. i hit an average of 100 to 200 file loses in the process. that's why i am reverting to a normal copy method (using fso to file.copy(destination & filename) but i need to connect first, hence this problem) as i do not think i would lose any files this way.

TimCottee,
thanx for the suggested site, i hope it is not another ftp methiod. i haven't check it out yet but will be looking into it immediately. will give more feedback afterds, ok?
0
 
TimCotteeHead of Software ServicesCommented:
kacang, please don't use the refresh button on your browser as this creates the duplicate posts. Use the "Reload Question" link at the top of the page instead.
0
 
priya_pbkCommented:
kacang,

I tried the fso, and was able to copy the folder to my server without giving the username and password(assuming your server is in network )

This is what I did,

--------------------------------
'Give reference to Miscrosoft Scripting Runtime
'declarations

Dim fso As New Scripting.FileSystemObject

Private Sub Command1_Click()
fso.CopyFolder "c:\TmpstockIdeaFiles", "\\ComputerName\c\inetpub\wwwroot\project\priya\"
End sub

--------------------------------------


This will copy all files of TmpstockIdeaFiles to priya folder. Do'nt give your IP address. Give the full path.

-priya
0
 
kacangAuthor Commented:
priya_pbk,
thanx 4 ur suggestion :) however, i am trying to avoid using the ftp protocol as i hit a number of files lost in transfer. currently, my program does the file porting via ftp and i am transfering between 1,000 to 3,000 files. i hit an average of 100 to 200 file loses in the process. that's why i am reverting to a normal copy method (using fso to file.copy(destination & filename) but i need to connect first, hence this problem) as i do not think i would lose any files this way.

TimCottee,
thanx for the suggested site, i hope it is not another ftp methiod. i haven't check it out yet but will be looking into it immediately. will give more feedback afterds, ok?
0
 
kacangAuthor Commented:
ops... sorry guys :) thanx tim for the reload question tip.

priya,
the reason u do not have problem copying is due to you being able to access that server already. try copying a file to a server that you need to connect using a user name and password and you would hit a "pathname not found error".

tim,
i can't seem to be able tto access the site you suggested. dunno if it's due to my office firewall...
will do some research into api method for the moment...
0
 
kacangAuthor Commented:
hello tim,
i finally managed to access the site you recommended. went thru the codes. yup! this is somewhat similar to what i need. so, i'll be awarding you the points. btw, how do u use api to transfer file (just curious) and thanx 4 ur help :)

priya,
i'm sorry for not awarding you the points, but tim's tip helped me solve my problem. where else yours, i have already tried and failed. thanx for your efford anyway :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now