Example





In This Topic

GetStat Method (GdPictureImaging)

In This Topic
Returns the status of the last executed operation with the current GdPictureImaging object.
Syntax
'Declaration
 
Public Function GetStat() As GdPictureStatus
public GdPictureStatus GetStat()
public function GetStat(): GdPictureStatus; 
public function GetStat() : GdPictureStatus;
public: GdPictureStatus GetStat(); 
public:
GdPictureStatus GetStat(); 

Return Value

A member of the GdPictureStatus enumeration. If the last executed GdPictureImaging method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
Use this method in the combination with all those, which return a value instead of a status, for example all CreateGdPictureImageFrom... methods.

Please note that to identify possible printing errors you should use the PrintGetLastError method and to identify possible TWAIN errors you should use the TwainGetLastResultCode method.

Example
Retrieving the status of the last executed operation.
Saving the image as a PDF document after the image has been successfully created.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
    if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
    {
        // Get the file path of the loaded image file.
        string filePath = gdpictureImaging.GetLastPath();
        string pdfPath = System.IO.Path.ChangeExtension(filePath, ".pdf");
 
        // Get the current version of the GdPicture.NET toolkit.
        string version = (gdpictureImaging.GetVersion()).ToString();
        version = version.Insert(version.IndexOf('.') + 2, ".");
 
        // Define the document properties when saving, for example, the current version of the GdPicture.NET toolkit.
        gdpictureImaging.SaveAsPDF(imageID, pdfPath, false, "Saving image as PDF", "GdPicture ver." + version.ToString(), "For test", "image, pdf", "Orpalis");
 
        gdpictureImaging.ReleaseGdPictureImage(imageID);
    }
    else
        MessageBox.Show("An image can't be created.\nError: " + gdpictureImaging.GetStat().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
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);
    }
}
See Also