29 Haziran 2016 Çarşamba

Text dosya Türkçe probleminin çözümü

string[] x = System.IO.File.ReadAllLines(@"c:\map.txt", Encoding.GetEncoding("windows-1254"));

Yukarı kod ile c:\map.txt dosyasındaki tüm satırları x isimli bir dizi içine satır satır aktarıyoruz. Aktarılanları görmek için aşağıdaki kod bloğunu kullanabilirsiniz
foreach (string s in x)
{
MessageBox.Show(s);
}

FTP ye dosya yükleme FTP Upload

FTP ye dosya yüklemek için kullanacağımız method aşağıdaki gibidir. 

public static Exception FtpUpload(string ftpadresi, string ftpusername, string ftppassword, string localadres, string dosyaadi)
        {
            try
            {
                string wftp = ftpadresi + "/" + dosyaadi;
                string wloc = localadres + "\\" + dosyaadi;
                using (WebClient client = new WebClient())
                {
                    client.Credentials = new NetworkCredential(ftpusername, ftppassword);
                    client.UploadFile(wftp, "STOR", wloc);
                }
                return null;
            }
            catch(Exception ex)
            {
                return ex;
            }
        }

Metodun Kullanımı

if (FtpUpload("ftp://192.168.1.67:3129","xxx","yyy","c:\\deneme","ornek.txt) == null)
{
MessageBox.Show("Başarılı");
}