Translate

22 Eylül 2021 Çarşamba

What is jQuery?



What is jQuery?

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.


1
$( "button.continue" ).html( "Next Step..." )

Event Handling

Show the #banner-message element that is hidden with display:none in its CSS when any button in #button-container is clicked.

1
2
3
4
var hiddenBox = $( "#banner-message" );
$( "#button-container button" ).on( "click", function( event ) {
hiddenBox.show();
});

Ajax

Call a local script on the server /api/getWeather with the query parameter zipcode=97201 and replace the element #weather-temp's html with the returned text.

1
2
3
4
5
6
7
8
9
$.ajax({
url: "/api/getWeather",
data: {
zipcode: 97201
},
success: function( result ) {
$( "#weather-temp" ).html( "<strong>" + result + "</strong> degrees" );
}
});

5 Temmuz 2021 Pazartesi

C# ILE FTP ÜZERINDE DOSYA VE KLASÖR İŞLEMLERI

 Microsoftun bize hazır sundugu sınıflardan biri olan FtpWebRequest Class'ı  ile işlemlerimizi rahatlıkla yerine getirebiliyoruz. FtpWebRequest class'ımız System.Net  namespace'i altında bulunmaktadır. aşağıda gösterdigimiz kodları uygularken import etmeyi unutmayın. Bu sınıfımızın haricinde System.IO'yada ihtiyacımız olucak.

FTP ile Dosya Gönderme
01FileInfo filei= new FileInfo(“DosyaAdresi”);
02string adres="domain veya server ipsi";
03string path = adres + filei.Name;
04FtpWebRequest FTP;
05FTP = (FtpWebRequest)FtpWebRequest.Create(new path(path));
06FTP.Credentials = new NetworkCredential("kullanıcıadı""Şifre");
07FTP.KeepAlive = false;
08FTP.Method = WebRequestMethods.Ftp.UploadFile;
09FTP.UseBinary = true;
10FTP.ContentLength = filei.Length;
11int buffLength = 1024;
12byte[] buff = new byte[buffLength];
13int contentLen;
14FileStream FS = filei.OpenRead();
15try
16{Stream strm = FTP.GetRequestStream();contentLen = FS.Read(buff, 0, buffLength);while (contentLen != 0)
17{strm.Write(buff, 0, contentLen);contentLen = FS.Read(buff, 0, buffLength);
18}
19strm.Close();
20FS.Close();Console.WriteLine("Başarılı");
21}catch (Exception ex)
22{
23Console.WriteLine(ex.Message);
24}
İşlemimizde öncelikle upload edicegimiz dosya yolunu alıyoruz daha sonra göndermek istedigimiz ftp deki yolunu belirliyoruz.sınıfımızı tanıplayıp ftp mizin kullanıcı adı şifresini,uygulayacağımız işlemin metodunu,veriyi gönderme türünü,dosya boyutunu ve son olarak buffer boyutunu belirtiyoruz.buffer dediğimiz olay anlık olarak gönderilcek  veri boyutudur.en sonda gönderme işlemini gerçekleştirip işlemimizi bitiriyoruz. Dikkat edersinizki try catch içine aldıgımız blok bu işlemi yapıyor. bi sorun olmazsa başarılı, olursada ekrana neden başarısız olduguyla ilgili hata mesajını ekrana yazdırıyor.
FTP ile Dosyaları Listelemek
01string[] Dosyalar;
02StringBuilder result = new StringBuilder();
03FtpWebRequest FTP;
04try
05{FTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(serveripsi veya domain));
06FTP.UseBinary = true;
07FTP.Credentials = new NetworkCredential("kullanıcı adı ""şifre");
08FTP.Method = WebRequestMethods.Ftp.ListDirectory;
09WebResponse response = FTP.GetResponse();
10StreamReader reader = new StreamReader(response.GetResponseStream());
11string line = reader.ReadLine();while (line != null)
12{
13result.Append(line);
14result.Append("\n");
15line = reader.ReadLine();
16}
17result.Remove(result.ToString().LastIndexOf('\n'), 1);
18reader.Close();
19response.Close();Dosyalar=result.ToString().Split('\n');for (int sayac = 0; sayac < downloadFiles.Length; x++)
20{
21Console.WriteLine(Dosyalar[sayac].ToString));
22}
23}catch (Exception ex)
24{
25Console.WriteLine(ex.Message);
26}
burdada görüldüğü gibi bir önceki kodlarımızla karşılaştırdığımızda farklılıklar dikkatinizi çekicektir. öncelikle methodumuz değişti.Ftpmize istek gönderiyoruz,cevap alıyoruz,stream reader yardımıyla okutuyoruz ve satır satır yazdırma işlemimizi gerçekleştiriyoruz.
Ftp ile Dosya indirme
01FtpWebRequest
02FTP;
03try
04{
05FileStream SR = new FileStream("C:\\" "Dosyaismi",FileMode.Create);
06FTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("serveripsiveya domain/"+ “Dosyaismi”);
07FTP.Credentials =new NetworkCredential("kullanıcıadı""Şifre");
08FTP.Method =WebRequestMethods.Ftp.DownloadFile;
09FTP.UseBinary =true;
10FtpWebResponse response = (FtpWebResponse)FTP.GetResponse();
11Stream ftpStream = response.GetResponseStream();
12long cl = response.ContentLength;
13int bufferSize = 1024;
14int readCount;
15byte[] buffer = new byte[bufferSize];
16readCount = ftpStream.Read(buffer, 0, bufferSize);
17while (readCount > 0)
18{
19SR.Write(buffer, 0, readCount);
20readCount = ftpStream.Read(buffer, 0, bufferSize);
21}
22ftpStream.Close();
23SR.Close();
24response.Close();
25Console.WriteLine("başarılı");}
26catch (Exception ex)
27{Console.WriteLine(ex.message);}
bilgisayarımıza nereye indircegimizin dosya yolunu giriyoruz. ftpden indirmek istediğimiz dosya yolunu yazıyoruz. bağlantı bilgilerimizi veriyoruz. metodumuzu WebRequestMethods.Ftp.DownloadFile  olarak değiştiriyoruz. response'umuzu webresponse türüne dönüştürüyoruz buffer bilglerimizide girip işlemi başlatıyoruz.
FTP ile Dosya Silme
01FtpWebRequest FTP;
02try
03{
04FTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("serveripveya domain/+“Dosyaismi”);
05FTP.UseBinary =true;
06FTP.Credentials =new NetworkCredential("kullanıcıadı""Şifre");
07FTP.Method =WebRequestMethods.Ftp.DeleteFile;
08FtpWebResponse response = (FtpWebResponse)FTP.GetResponse();
09Console.WriteLine(response.StatusDescription);
10}
11catch (Exception ex)
12{
13Console.WriteLine(ex.Message);
14}
yukarda digerlerinde olmayan bir komut gördünüz.  "response.StatusDescription"  adındanda anlaşılağı üzere isteğimize karşılık gelen cevapta durumundan haberdar oluyoruz. başarılımı değil mi şeklinde.
FTP ile Klasör Silme
01FtpWebRequest FTP;
02try
03{
04FTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("serveripsi veya domain/"+ “Silinecekklasörismi” +"/"));
05FTP.UseBinary =true;FTP.Credentials =new NetworkCredential("kullanıcıadı""Şifre");
06FTP.Method =WebRequestMethods.Ftp.RemoveDirectory;
07FtpWebResponse response = (FtpWebResponse)FTP.GetResponse();
08Console.WriteLine(response.StatusDescription);
09}
10catch (Exception ex)
11{
12Console.WriteLine(ex.Message);
13}
FTP ile Klasör Oluşturma
01FtpWebRequest FTP;
02try
03{
04FTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("serveripsi veya domain/"+ “Yeniklasörismi” +“/”));
05FTP.UseBinary =true;
06FTP.Credentials =new NetworkCredential("kullanıcıadı""Şifre");
07FTP.Method =WebRequestMethods.Ftp.MakeDirectory;
08FtpWebResponse response = (FtpWebResponse)FTP.GetResponse();
09Console.WriteLine(response.StatusDescription);
10}
11catch (Exception ex)
12{
13Console.WriteLine(ex.Message);
14}
FTP ile Dosya Adı Değiştirme
01FtpWebRequest FTP;
02try
03{
04FTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("serveripsi veya domain/+“Dosyaismi”);
05FTP.UseBinary = true;
06string yeniisim="dosyaismi";
07FTP.RenameTo = yeniisim;
08FTP.Credentials = new NetworkCredential("kullanıcıadı""Şifre");
09FTP.Method = WebRequestMethods.Ftp.Rename;
10FtpWebResponse response = (FtpWebResponse)FTP.GetResponse();
11Console.WriteLine(response.StatusDescription);
12}
13catch (Exception ex)
14{
15Console.WriteLine(ex.Message);
16}
işlemlerimiz bukadar.Gördügünüz gibi çogunda bir değişiklik yok sadece methodu değiştirmemiz işlemimizin gidişatını değiştiriyor. Bunun haricinde FTPlib olarak geçen FTP Client Library  sınıfınında oldukça kullanışlı olduğunu söleyebilirim. Okuduğunuz için

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Powered by Blogger | Printable Coupons