Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: VB.NET: How to interpret Upload Results

as1981 wrote:

If my transfer operation is transferring more than one file could I get more than one error message? So for example could I have a message in TransferOperationResult.Failures[0].Message and TransferOperationResult.Failures[1].Message?

Quite rarely, but it is possible.

If that it the situation then can I get a count of the failures and loop through them? Maybe TransferOperationResult.Failures.count?

It's .Count (capital C, while that does not matter in VB.NET).
The Failures is a ICollection.
as1981

Re: VB.NET: How to interpret Upload Results

martin wrote:

Correct, use TransferOperationResult.IsSuccess.

If you need the error message, see TransferOperationResult.Failures[0].Message (C# syntax) and any inner exceptions for yet more details.

See https://winscp.net/eng/docs/library_transferoperationresult


Hello,

If my transfer operation is transferring more than one file could I get more than one error message? So for example could I have a message in TransferOperationResult.Failures[0].Message and TransferOperationResult.Failures[1].Message?

If that it the situation then can I get a count of the failures and loop through them? Maybe TransferOperationResult.Failures.count?

Thanks

Andrew
martin

Re: IsSuccess

kamii47 wrote:

One odd thing i have notice about this TransferOperationResult is that when i have a file name like test[46]_2.iso e.t.c though file hasn't been transfered but i still get ISSuccess = true.
I know the issue was because of special characters in the file name but this IsSuccess is not releable. you can simply list the directory where you have uploaded the file and check the existence of the filename in that list

It is reliable. The test[46]_2.iso is a file mask. If there's no file matching the file mask (and the test[46]_2.iso file does NOT match the test[46]_2.iso mask), then WinSCP won't transfer anything. And it's not an error, hence the IsSuccess is true. If you expect something to transfer, test also TransferOperationResult.Transfers.Count > 0. Anyway, the actual solution is to pass the filename though Session.EscapeFileMask before passing it to Session.GetFiles or Session.PutFiles.

It's actually documented:
https://winscp.net/eng/docs/library_wildcard
ianbhenderson73

Re: IsSuccess

kamii47 wrote:

One odd thing i have notice about this TransferOperationResult is that when i have a file name like test[46]_2.iso e.t.c though file hasn't been transfered but i still get ISSuccess = true.
I know the issue was because of special characters in the file name but this IsSuccess is not releable. you can simply list the directory where you have uploaded the file and check the existence of the filename in that list


My only concern with that approach is that the company that runs the remote server has scripts set up which detect the presence of an incoming file and transfer that file elsewhere for processing. Whilst a directory list would work in the majority of cases, there may be instances where the remote script will run in that split second between the file being placed and the directory list being completed.
kamii47

Re: IsSuccess

One odd thing i have notice about this TransferOperationResult is that when i have a file name like test[46]_2.iso e.t.c though file hasn't been transfered but i still get ISSuccess = true.
I know the issue was because of special characters in the file name but this IsSuccess is not releable. you can simply list the directory where you have uploaded the file and check the existence of the filename in that list
ianbhenderson73

Hi both

Many thanks for coming back to me. I've yet to test my implementation but on the face of it, the code that you've both supplied looks as if it'll do what I need it to do.
martin

Re: VB.NET: How to interpret Upload Results

Correct, use TransferOperationResult.IsSuccess.

If you need the error message, see TransferOperationResult.Failures[0].Message (C# syntax) and any inner exceptions for yet more details.

See https://winscp.net/eng/docs/library_transferoperationresult
as1981

Hello,

I'm not using .net but I think you can use transferResult.IsSuccess or something similar. It returns true or false.

Thanks

Andrew
ianbhenderson73

VB.NET: How to interpret Upload Results

Hi

I've been using WinSCP for years, but this is the first time I've done it using a .NET assembly.

I'm in the process of writing an application which will automatically generate a file and then transfer them to a supplier's sFTP site. I've managed to get pretty much everything written, but now I want to be able to verify that the upload was successful. Since this application is going to be running constantly and generating files as and when the need arises, it'll effectively be unattended and therefore I'd want to be able to populate information into a SQL database table which shows the success (or otherwise) of each stage in the process.

The code that I've written in VB.net creates new SessionOptions, Session, TransferOptions and TransferOperationResult objects and populates those as needed. I'd hoped there might be a member of TransferOperationResult which would tell me the success/failure status of the transfer in progress, preferably with some supporting information if the transfer failed. So far though, I've been unable to find anything.

If anyone can provide me with details of where I need to look, I'll be extremely grateful.

TIA

Is there any way of catching the status of an upload? I've tried various