none
Copy file from SFTP RRS feed

  • 質問

  • Hi all,
    I need to create an application which copies files from SFTP and paste them on my computer.

    Can anyone please tell me how can I do this. I do not want to use any library of other providers like j* or others.

    Regards,
    Kunal

    2009年5月28日 12:18

回答

すべての返信

  • Hmm, SFTP is very obscure these days.  Copying files without any error checking just isn't very popular.  Anyhoo, .NET only supports FTP, you'll have to find a library elsewhere.

    Hans Passant.
    2009年5月28日 12:50
    モデレータ
  • Hmm, SFTP is very obscure these days.  Copying files without any error checking just isn't very popular.  Anyhoo, .NET only supports FTP, you'll have to find a library elsewhere.

    Hans Passant.

    Hi,

    Does that mean: Using pure C# we cannot connect to a FTP server using SFTP?

    Please clear my doubt..

    Thanks,
    Sumit
    2009年5月28日 18:02
  • You cannot do anything at all with "pure C#".  It needs a library.  .NET is a library, but not one that supports SFTP.  A quick google search turned up plenty of code samples.  Here's a professional product .

    Hans Passant.
    • 回答としてマーク Zhi-Xin Ye 2009年6月3日 10:54
    2009年5月28日 21:41
    モデレータ
  • Hi all,
    I need to create an application which copies files from SFTP and paste them on my computer.

    Can anyone please tell me how can I do this. I do not want to use any library of other providers like j* or others.

    Regards,
    Kunal


    Try with SFTP free component keyword: http://www.google.com/search?hl=en&biw=1024&bih=707&q=sftp+free+component&aq=f&aqi=&aql=&oq=&gs_rfai=

    People have been talking about SSH Sharp Lib. But you need to spend some effort.

    2010年9月28日 7:10
  • It means downloading files from a remote SFTP server. You may need the Ultimate SFTP component . Here is an example code to do so:

    // Create a new instance.
    Sftp client = new Sftp();
    // Connect to the SFTP server.
    client.Connect( "localhost" );
    // Authenticate.
    client.Authenticate( "test" , "test" );
    // ...
    // Get all directories, subdirectories, and files from remote folder '/myfolder' to 'c:\myfolder'.
    client.DownloadFiles( "/myfolder" , "c:\\myfolder" );
    // Get all directories, subdirectories, and files that match the specified search pattern from remote folder '/myfolder2' to 'c:\myfolder2'.
    client.DownloadFiles( "/myfolder2" , "c:\\myfolder2" , "*.cs" );
    // or you can simply put wildcard masks in the source path, our component will automatically parse it.
    // download all *.css files from remote folder '/myfolder2' to local folder 'c:\myfolder2'.
    client.DownloadFiles( "/myfolder2/*.css" , "c:\\myfolder2" );
    // Download *.cs and *.vb files from remote folder '/myfolder2' to local folder 'c:\myfolder2'.
    client.DownloadFiles( "/myfolder2/*.cs;*.vb" , "c:\\myfolder2" );
    // Get files in the folder '/myfolder2' only.
    TransferOptions opt = new TransferOptions(true, false, false, (SearchCondition) null , FileExistsResolveAction.OverwriteAll, SymlinksResolveAction.Skip, false);
    client.DownloadFiles(
    "/myfolder2" , "c:\\myfolder2" , opt);
    // ...
    // Disconnect.
    client.Disconnect();

    Some other code examples can be found on Ultimate SFTP's Blog
    2010年10月6日 20:30