Dosya Kopyalama Hk. (Win From Linux)
-
Merhaba arkadaşlar,
winscp ile bağlandığımız bir linux sunucudaki cache klasörünün içeriğini belirlli aralıklarla kopyalamak istiyorum. Bunu c# ile nasıl yapabilirim?
-
C# ssh library hocam
-
teşekkür ettim hojucuk hocam ;)
-
you're always welcome hocam .P
-
Nette bulduğum bir kaç döküman ile sorunumu çözdüm. Lazım olan olur google indexler vs diye koyayım buraya..
String CacheMap = @"/OraRep/reports/cache/"; SftpClient sftp = new SftpClient("server", "Kullanıcı adı", "şifre"); List<string> PdfList = new List<string>(); private void btnGetPdfFiles_Click(object sender, EventArgs e) { sftp.Connect(); var files = sftp.ListDirectory(CacheMap); foreach (var item in files) { PdfList.Add(item.Name); if (item.Name != "." && item.Name != "..") { DownloadPDFFiles(item.Name); } } lstPdfList.DataSource = PdfList; } private void DownloadPDFFiles(String pFileName) { sftp.Connect(); string FromPath = CacheMap + pFileName, StoragePath = ""; if (File.Exists(StoragePath)) File.Delete(StoragePath); if (!Directory.GetDirectories(Path.GetTempPath()).Contains("PDFFiles")) { Directory.CreateDirectory(Path.GetTempPath() + "PDFFiles"); } StoragePath = Path.GetTempPath() + "PDFFiles\\"+pFileName; Int64 iSize = sftp.ReadAllBytes(FromPath).Length; Int64 iRunningByteTotal = 0; using (Stream streamRemote = sftp.OpenRead(FromPath)) { using (Stream streamLocal = new FileStream(StoragePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) { int iByteSize = 0; byte[] byteBuffer = new byte[iSize]; while ((iByteSize = streamRemote.Read(byteBuffer, 0, byteBuffer.Length)) > 0) { streamLocal.Write(byteBuffer, 0, iByteSize); iRunningByteTotal += iByteSize; } } } } -
eline saglik
Toplam Hit: 884 Toplam Mesaj: 6
