TReKiE / msnp-sharp

Automatically exported from code.google.com/p/msnp-sharp
0 stars 0 forks source link

How to Cancel File transfering #194

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
MSNPSharp Version 2.5.8.

I want to cancel a running file transfer while it is doing.

But I really do not find how and where to call
"P2PTransferSession.AbortTransfer()".

Could you give some tips ? thanks.

Original issue reported on code.google.com by 2884...@gmail.com on 24 May 2010 at 9:14

GoogleCodeExporter commented 9 years ago
Hello,
This is not an issue, this is your question. If you have question, please email 
me 
at: freezingsoft@hotmail.com

Regards,
Pang WU

Original comment by freezing...@gmail.com on 24 May 2010 at 2:27

GoogleCodeExporter commented 9 years ago
The following is the tip, but you should email me next time:

//You use the following code to start a file transfer:
MSNSLPHandler msnslpHandler = _messenger.GetMSNSLPHandler(contact);
FileStream fileStream = new FileStream(filename, FileMode.Open, 
FileAccess.Read, 
FileShare.Read);
P2PTransferSession session = msnslpHandler.SendInvitation
(_messenger.ContactList.Owner, contact, Path.GetFileName(filename), fileStream);

//To cancel it, just try:
session.AbortTransfer();

Original comment by freezing...@gmail.com on 24 May 2010 at 2:32

GoogleCodeExporter commented 9 years ago
//If you are the receiver of a file transfer, you should do as follows:
//You use this piece of code to accept a file transfer (Please refer the 
DotMSN.cs 
if you don't know what I am talking about)

e.TransferSession.DataStream = new FileStream(saveFileDialog.FileName, 
FileMode.Create, FileAccess.Write);
e.Accept = true;
e.TransferSession.AutoCloseStream = true;

//So e.TransferSession is the P2PTransferSession. If you want to cancel, please 
save 
the TransferSession object and call AbortTransfer()
e.TransferSession.AbortTransfer();

Original comment by freezing...@gmail.com on 24 May 2010 at 2:39