Solved

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

Posted on 2002-05-30
12
147 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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 …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

707 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