SetFtpPassiveMode Method (GdPictureImaging)
In This Topic
Specifies if the FTP transfer mode used by
GdPictureImaging.CreateGdPictureImageFromFTP method is Passive or not. The initial value is true.
Syntax
'Declaration
Public Sub SetFtpPassiveMode( _
ByVal As Boolean _
)
public void SetFtpPassiveMode(
bool
)
public procedure SetFtpPassiveMode(
: Boolean
);
public function SetFtpPassiveMode(
: boolean
);
public: void SetFtpPassiveMode(
bool
)
public:
void SetFtpPassiveMode(
bool
)
Parameters
- PassiveMode
- Set this parameter to true, if you want to use the passive FTP transfer, otherwise set it to false.
Example
Setting up the FTP transfer mode.
Uploading an image to a file located on a distant server using FTP transfer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Set the transferring options.
gdpictureImaging.SetFtpPassiveMode(true);
gdpictureImaging.SetHttpTransferBufferSize(2048);
if (gdpictureImaging.UploadFileToFTP(@"D:\images\image.jpg", "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Uploading failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Uploading using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Saving an image to a file located on a distant server using FTP transfer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
// Set the active FTP transfer more.
gdpictureImaging.SetFtpPassiveMode(false);
if (gdpictureImaging.SaveToFTP(imageID, GdPicture14.DocumentFormat.DocumentFormatJPEG, 75, "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Saving failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Saving using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Example
Setting up the FTP transfer mode.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Set the transferring options.
gdpictureImaging.SetFtpPassiveMode(true);
gdpictureImaging.SetHttpTransferBufferSize(2048);
if (gdpictureImaging.UploadFileToFTP(@"D:\images\image.jpg", "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Uploading failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Uploading using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
// Set the active FTP transfer more.
gdpictureImaging.SetFtpPassiveMode(false);
if (gdpictureImaging.SaveToFTP(imageID, GdPicture14.DocumentFormat.DocumentFormatJPEG, 75, "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Saving failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Saving using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also