Solved

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

Posted on 2002-05-30
12
151 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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
 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using "ScreenUpdating" 6 88
Spell Check in VB6 13 152
Excel VBA - Run Time error '1004' Application-defined or object-defined error 4 534
checkbox to hide entire section 10 76
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

710 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