Hello all,
We are connecting to a remote server using FTP and sending up 100's of files
daily to this site. I just received a call from the operations manager of
this site and they are complaining that we are doing a CD.. in our
connection prior to uploading. Once we signon, they claim we are "in" the
correct folder. I have adopted this code from another programmer who is
long gone. I do not see anything in this code that would cause it to do a
CD.. once connected to the site and then do a CD into the appropriate
folder. Does the FTP object have a setting I can change that will get rid
of this behavior? We are calling the following class like:
Private _ftp As FtpClient
.....
_ftp = New Ftpclient(Me)
...._ftp.DoZipU pload()
Below is the code for the FtpClient class. Any ideas would be greatly
appreciated!
Imports System.Net
Imports System.IO
Public Class Ftpclient
Private Base As EtiBase
Sub New(ByRef aEtiBase As EtiBase)
Base = aEtiBase
End Sub
Public Sub DoZipUpload()
Base.LogToSumma ry("Uploading data.")
DoUpload(Base.I ni.outputzipfil ename, Base.Ini.ftpuse r,
Base.Ini.ftppas swordtext, Base.Ini.ftpser ver, Base.Ini.ftppas sive)
End Sub
Private Sub AttemptFtpConne ct(ByVal username As String, ByVal password As
String, ByVal UsePassive As String, ByVal uploadUrl As String, ByRef
requestStream As Stream, ByRef uploadRequest As FtpWebRequest)
uploadRequest = Nothing
requestStream = Nothing
Try 'attempt connect
uploadRequest = WebRequest.Crea te(uploadUrl) 'set connection options
uploadRequest.M ethod = WebRequestMetho ds.Ftp.UploadFi le
uploadRequest.P roxy = Nothing 'no proxy, no passive
uploadRequest.U sePassive = Convert.ToBoole an(UsePassive)
uploadRequest.C redentials = New NetworkCredenti al(username, password)
requestStream = uploadRequest.G etRequestStream ()
Base.LogToSumma ry(vbCrLf & "FTP connect success.")
Catch ex As Exception
Base.LogToSumma ry(vbCrLf & "FTP connect failed.")
Base.LogToDebug (String.Format( "exception! message:[{0}] source:[{1}]",
ex.Message, ex.Source))
End Try
End Sub
Private Sub DoUpload(ByVal fileName As String, ByVal username As String,
ByVal password As String, ByVal host As String, ByVal UsePassive As String)
Base.ParentForm .SetText("Attem pting to connect to ftp...")
Base.LogToDebug (String.Format( "ftp: host[{0}] user[{1}] password-length[{2}]
file[{3}]", host, username, password.Length , fileName))
Dim uploadUrl As String = "ftp://" & host & "/" & Path.GetFileNam e(fileName)
Dim requestStream As Stream = Nothing
Dim uploadRequest As FtpWebRequest = Nothing
'try to get ftp conenction
AttemptFtpConne ct(username, password, UsePassive, uploadUrl, requestStream,
uploadRequest)
'retry if failed
If requestStream Is Nothing Then
Base.WaitForSer ver(host)
AttemptFtpConne ct(username, password, UsePassive, uploadUrl, requestStream,
uploadRequest)
End If
'retry if failed
If requestStream Is Nothing Then
Base.WaitForSer ver(host)
AttemptFtpConne ct(username, password, UsePassive, uploadUrl, requestStream,
uploadRequest)
End If
'if failed give up
If requestStream Is Nothing Then
Base.successorf ail = "FAILURE"
Base.failreason = "Cannot connect to FTP server."
End If
'send file over connection
If Not requestStream Is Nothing Then
SendFile(fileNa me, requestStream, uploadRequest)
End If
Base.ParentForm .SetText("Uploa d was a " & Base.successorf ail)
End Sub
Private Sub SendFile(ByRef filename As String, ByRef requestStream As
Stream, ByRef uploadRequest As FtpWebRequest)
Base.ParentForm .SetText("Uploa ding data. 0% done.")
Dim fileStream As FileStream = Nothing
'get stats so we can update pretty gui status
Dim f As New System.IO.FileI nfo(filename)
Dim fileSize As Long = f.Length
f = Nothing
Dim lastPercent As Integer = 0
Dim totalSent As Long = 0
'read local file in chunks, copying to server
fileStream = File.Open(filen ame, FileMode.Open)
Dim buffer(1024) As Byte
Dim bytesRead As Integer
Try
While True
'read from file
bytesRead = fileStream.Read (buffer, 0, buffer.Length)
If bytesRead = 0 Then
Exit While
End If
'write to ftp stream
requestStream.W rite(buffer, 0, bytesRead)
'log percent to gui if changing
totalSent = totalSent + bytesRead
lastPercent = System.Math.Tru ncate(100 * (totalSent / fileSize))
If lastPercent Mod System.Convert. ToInt16(Base.In i.refreshgui) = 0 Then
Base.ParentForm .SetText(String .Format("Upload ing data. {0:F0}% done.",
lastPercent))
End If
End While
Catch ex As Exception
Base.LogToSumma ry(vbCrLf & "Data upload failed before completion.")
Base.LogToDebug (String.Format( "exception! message:[{0}] source:[{1}]",
ex.Message, ex.Source))
Base.successorf ail = "FAILURE"
Base.failreason = "Data upload failed before completion."
End Try
requestStream.C lose()
'make sure server took it, look for server to say complete
Dim uploadResponse As FtpWebResponse = Nothing
uploadResponse = uploadRequest.G etResponse()
If uploadResponse. StatusDescripti on.ToLower.Cont ains("transfer complete") Or
uploadResponse. StatusDescripti on.StartsWith(" 226") Then
Base.LogToSumma ry(vbCrLf & "Data upload successful.")
Base.successorf ail = "SUCCESS"
Else
Base.LogToSumma ry(vbCrLf & "Data upload complete, but remote server failed
to confirm reception.")
Base.successorf ail = "FAILURE"
Base.failreason = "Data upload complete, but remote server failed to confirm
reception."
End If
uploadResponse. Close()
requestStream.C lose()
fileStream.Clos e()
End Sub
End Class 1 1468
No takers? Is there a different group I should post this message to? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: cwizard |
last post by:
I'm calling on a function from within this form, and there are values set
but every time it gets called I get slammed with a run time error...
document.frmKitAmount.txtTotalKitValue is null or not an object... the
function is like so:
function calc_total()
{
var x,i,base,margin,total,newmargin,newtotal;
base = document.frmKitAmount.txtTotalKitValue.value;
margin = document.frmKitAmount.margin.value/100;
|
by: DrUg13 |
last post by:
In java, this seems so easy. You need a new object
Object test = new Object() gives me exactly what I want.
could someone please help me understand the different ways to do the
same thing in C++. I find my self sometimes, trying
Object app = Object();
Object *app = Object();
Object app = new Object();
|
by: Louis LeBlanc |
last post by:
Hey folks. I'm new to the list, and not quite what you'd call a DB
Guru, so please be patient with me. I'm afraid the lead up here is a
bit verbose . . .
I am working on an application that uses very high volume DB
transactions - in the order of tens of millions per day . . .
Anyway, the current database which will remain nameless, but begins
with O and rymes with debacle (sorta), has a problem with high volume
work when it comes to...
|
by: cedgington |
last post by:
I wanted to take advantage of the large set of functionality offered by
the framework, so for my latest project I'm using managed C++ with .NET
v2. I'm using the gcnew operator in two different ways, and I'm
confused about the lifetime of objects and whether or not I should be
calling delete. Here are two examples:
ref class SYMBOL : public IComparable
{
public:
// Constructor / destructor
|
by: Crimson* |
last post by:
I've got a table with an entry type as "OLE Object" in Access 2003. In the
form that the table is linked to I want to insert an image (BMP) for each
record. However, when I attempt to do so the file is inserted and the
filename (image.bmp) is inserted in the box with it taking up about half of
the box. I didn't have this problem in Access XP. I've tried embedding and
linking the file, but this always happens. Can anyone offer any...
| |
by: sammyboy78 |
last post by:
I need to create a method for sorting my CD objects by the CD Title. I have no idea where to begin. I haven't yet covered any sorting algorithms so I need to know how I can sort this thing. I'm not asking for someone to write the code for me I just need some direction. Here's the code:
// CD.java
// Represents a compact disc object
class CD
{
private String title; // CD title (name of product)
private String number; // CD...
|
by: Rob |
last post by:
I have a vector of a class type and when I create an object inside a
function and return that and add it to the vector, it doesn't properly
keep the data inside it. So I have a few questions:
1. Is this because it loses scope since it wasn't created with "new"?
2. If I do create it with new, but the vector holds objects not
pointers, will the vector's "delete" operator function still handle
deleting all those pointers?
CODE 1:
|
by: Maarten |
last post by:
Howdy,
Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.
For extracting a bit of info from my cd's I have an executable which I
execute with exec():
$discOutput = exec('./discid /dev/rdisk2');
|
by: whitep8 |
last post by:
Hi All,
Im quite new to java and im a little stuck with something so any help you can provide would be greatly appreciated.
I have 2 classes, a CD class and a CDDriver class.
The CD class has the stored variables and a toString accessor. the CD driver creates 3 instances of a CD object, which holds artist, title and cost.
What i wouldnt like to figure out, and ive spent ages doing it, is to count the number of classes (totalCD's)...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |