Click here to Skip to main content
15,887,376 members
Home / Discussions / C#
   

C#

 
QuestionOpenXML SDK - a link in MS Excel to open another MS Excel. how would the request be authenticated? Pin
Rijz27-Jun-12 19:20
Rijz27-Jun-12 19:20 
AnswerRe: OpenXML SDK - a link in MS Excel to open another MS Excel. how would the request be authenticated? Pin
Richard MacCutchan27-Jun-12 22:29
mveRichard MacCutchan27-Jun-12 22:29 
GeneralRe: OpenXML SDK - a link in MS Excel to open another MS Excel. how would the request be authenticated? Pin
Rijz27-Jun-12 23:47
Rijz27-Jun-12 23:47 
GeneralNeed some general feedback on my WCF Pin
Software200727-Jun-12 14:30
Software200727-Jun-12 14:30 
GeneralRe: Need some general feedback on my WCF Pin
Richard MacCutchan27-Jun-12 22:28
mveRichard MacCutchan27-Jun-12 22:28 
GeneralRe: Need some general feedback on my WCF Pin
Software200728-Jun-12 6:09
Software200728-Jun-12 6:09 
GeneralRe: Need some general feedback on my WCF Pin
Richard MacCutchan28-Jun-12 6:40
mveRichard MacCutchan28-Jun-12 6:40 
QuestionScope issue closing a connection after exception Pin
Harley Burton27-Jun-12 6:02
Harley Burton27-Jun-12 6:02 
Hello,
I'm having a problem where an exception is thrown while trying to download files, using the Tamir.SharpSSH library, if the files don't exist. It's expected behavior, however, after the exception is thrown I'm unable to close the connection because I lose scope. I'm sure there is a simple solution. I would appreciate any help. The code is currently...

C#
try
                {
                    Sftp sftp = new Sftp(sftpServer, sftpUserName);
                    sftp.Password = sftpPassword;
                    sftp.OnTransferProgress += new FileTransferEvent(sftp_OnTransferProgress);
                    sftp.OnTransferStart += new FileTransferEvent(sftp_OnTransferStart);
                    sftp.Connect(22);
                    if (sftp.Connected)
                    {
                        DateTime now = DateTime.Now;
                        string year = now.Year.ToString();
                        string month = now.Month.ToString();
                        if (month.Length < 2) { month = "0" + month; }
                        Log("Attempting to download all files from todalton directory for the current month");
                        sftp.Get("balance//todalton//daltonAutoload" + year + month + "*", @"C:\higherone\");
//sftp.Close();
                        Log("Transfer Complete");
                    }
                }
                catch (Tamir.SharpSsh.jsch.SftpException)
                {
                    Log("No files of the given criteria exist on the server.\r\n\t\tDownload aborted."
                        + "\r\n\t :NOTE: If this is the first run of the month, this is the expected behavior.");
                }
                catch (Exception ex)
                {
                    Log(ex.Message + " :NOTE: sftp connection failed during download");
                }
                finally
                {
                    sftp.Close();
                }


I can't reach the Close method from within finally or either catch. Originally the close was where it is commented. Obviously the exception causes that line to be missed though.

Thanks
AnswerRe: Scope issue closing a connection after exception Pin
Pete O'Hanlon27-Jun-12 6:13
mvePete O'Hanlon27-Jun-12 6:13 
AnswerRe: Scope issue closing a connection after exception Pin
Luc Pattyn27-Jun-12 6:20
sitebuilderLuc Pattyn27-Jun-12 6:20 
SuggestionRe: Scope issue closing a connection after exception Pin
kisMicrosoftDev27-Jun-12 6:29
kisMicrosoftDev27-Jun-12 6:29 
GeneralRe: Scope issue closing a connection after exception Pin
Harley Burton27-Jun-12 6:57
Harley Burton27-Jun-12 6:57 
GeneralRe: Scope issue closing a connection after exception Pin
mohancbe27-Jun-12 21:11
mohancbe27-Jun-12 21:11 
AnswerRe: Scope issue closing a connection after exception Pin
Harley Burton14-Aug-19 4:37
Harley Burton14-Aug-19 4:37 
GeneralDrawImage with NearestNeighbor-Interpolation Pin
LionAM27-Jun-12 2:03
LionAM27-Jun-12 2:03 
GeneralRe: DrawImage with NearestNeighbor-Interpolation Pin
Luc Pattyn27-Jun-12 9:47
sitebuilderLuc Pattyn27-Jun-12 9:47 
GeneralRe: DrawImage with NearestNeighbor-Interpolation Pin
LionAM28-Jun-12 5:16
LionAM28-Jun-12 5:16 
Generallocal group to adam group problem Pin
caknoris27-Jun-12 1:38
caknoris27-Jun-12 1:38 
GeneralRe: local group to adam group problem Pin
lukeer27-Jun-12 2:59
lukeer27-Jun-12 2:59 
GeneralHow to make a word in a text modifiable(doubleClick, change color,..) in C# Pin
rongvangso727-Jun-12 0:23
rongvangso727-Jun-12 0:23 
AnswerRe: How to make a word in a text modifiable(doubleClick, change color,..) in C# Pin
Eddy Vluggen27-Jun-12 0:42
professionalEddy Vluggen27-Jun-12 0:42 
GeneralRe: How to make a word in a text modifiable(doubleClick, change color,..) in C# Pin
rongvangso727-Jun-12 5:07
rongvangso727-Jun-12 5:07 
GeneralRe: How to make a word in a text modifiable(doubleClick, change color,..) in C# Pin
Eddy Vluggen27-Jun-12 5:40
professionalEddy Vluggen27-Jun-12 5:40 
QuestionHow to put field at bottom of detail section in Crystal report Pin
maheshk_blr26-Jun-12 21:26
maheshk_blr26-Jun-12 21:26 
Questionmove App.Config to AppData folder Pin
Jassim Rahma26-Jun-12 21:04
Jassim Rahma26-Jun-12 21:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.