|
-
May 24th, 2012, 06:28 PM
#9
Re: Remote Server
Im trying to comunicate with a FTP server,where i want to execute a program,but i don`t know how.
what y want to perform with ftp ?download some files from ftp .upload on ftp or something other ?let me know very exactly .
Use a FTP Batch Script to download the file then you can use
use this method .try the following way .i have been using in hundreds of application .we are no one retail company in Kuwait city .go through the following way .
Code:
Public Function DownloadFile() As Boolean
Dim strMsg$
Dim strLine$
Dim gstrMessage$
Dim processID#
Dim process_handle#
Dim zipapfilepath$
Dim BatchPathLoc As String
Dim DownloadFilepath$
Dim FTPCommandList As String
'------------------------ Authentication--------------------------
DownloadFilepath = "\Inditexx\Download"
Call CheckInditexFolder(DownloadFilepath)
FTPCommandList = strDwnldFilePth & "\FTPCommandList.txt"
Open FTPCommandList For Output As #1
strLine = ""
strLine = "USERNAME" & vbCrLf & _
"PASSWORD" & vbCrLf & _
"ascii" & vbCrLf & _
"prompt off" & vbCrLf & _
"cd /outgoing/articles/" & vbCrLf & _
"mget ART*.ZIP" & vbCrLf & _
"close" & vbCrLf & _
"bye" & vbCrLf
Print #1, strLine
Close #1
BatchPathLoc = strDwnldFilePth & "\FTPDownBatchFile.bat"
Open BatchPathLoc For Output As #1
strLine = ""
strLine = "C:" & vbCrLf & _
"cd " & DownloadFilepath & vbCrLf & _
"C:\WINDOWS\system32\ftp.exe -s:" & FTPCommandList & " ftp1.inditex.com" & vbCrLf
Print #1, strLine
Close #1
'----------------------- Downloading Data with FTP ------------------------------
processID = Shell(BatchPathLoc, vbHide)
process_handle = OpenProcess(SYNCHRONIZE, 0, processID)
'NOT NEEDED--->If process_handle <> 0 Then
WaitForSingleObject process_handle, INFINITE
CloseHandle process_handle
'NOT NEEDED--->End If
gstrMessage = gstrMessage & "Searching for files in <IN> folder" & vbCrLf
'gstrMessageToUser = gstrMessageToUser & "Searching for files in <IN> folder" & vbCrLf
'
' Use your own path instead of \projectFTPData or create this folder on your C drive
'
If Dir$("c:\Inditexx\Download" & "\ART*.ZIP") = "" Then
strMsg = strMsg & "No files on FTP to download" & vbCrLf
MsgBox strMsg
Exit Function
Else
DownloadFile = True
strMsg = strMsg & "Files Downloaded from FTP" & vbCrLf
MsgBox strMsg
End If
End Function
Public Sub CheckInditexFolder(path As String)
If Dir("C:\Inditexx", vbDirectory) = "" Then
MkDir "C:\Inditexx"
End If
If Dir("C:\Inditexx\download", vbDirectory) = "" Then
MkDir "C:\Inditexx\download"
End If
End Sub
Last edited by firoz.raj; May 25th, 2012 at 05:49 AM.
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
|