Solved

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

Posted on 2002-05-30
12
148 Views
Last Modified: 2010-05-02
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
Comment
Question by:kacang
  • 6
  • 3
  • 3
12 Comments
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7044007
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
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 7044024
http://www.mvps.org/vbnet/code/network/netconnect.htm

May help in demonstrating how to make a connection to a network resource.
0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7044025
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
 

Author Comment

by:kacang
ID: 7044037
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
 
LVL 43

Expert Comment

by:TimCottee
ID: 7044046
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
 

Author Comment

by:kacang
ID: 7044048
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:kacang
ID: 7044057
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
 
LVL 43

Expert Comment

by:TimCottee
ID: 7044064
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
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7044113
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
 

Author Comment

by:kacang
ID: 7044159
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
 

Author Comment

by:kacang
ID: 7044164
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
 

Author Comment

by:kacang
ID: 7046223
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access 2003, my txt file export is running backwards 4 46
Validating VB6 Function 19 56
How to debug this code 7 56
How to Add / Edit Windows Menu 4 50
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now