Last active
December 26, 2015 19:59
-
-
Save veyselsahin/7205549 to your computer and use it in GitHub Desktop.
Global C# sınıfı
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Management; | |
using System.Net; | |
using System.Runtime.InteropServices; | |
using System.Text.RegularExpressions; | |
using System.Xml; | |
using System.Windows.Forms; | |
using System.Data.OleDb; | |
namespace WindowsFormsApplication6 | |
{ | |
public sealed class glb { | |
public static OleDbCommand komut = new OleDbCommand(); | |
public static OleDbConnection Conn = new OleDbConnection(); | |
public string server; | |
public string port; | |
public string db; | |
public string user; | |
public string parola; | |
public static class FINANS | |
{ | |
public static string KDVTutar(double tutar) | |
{ | |
return String.Format("{0:0.00}", (tutar * 0.18)); | |
} | |
public static string KdvTopla(double tutar) | |
{ | |
return String.Format("{0:0.00}", tutar + Convert.ToDouble( (KDVTutar(tutar)))); | |
} | |
public static string YuzdelikEkle(double tutar,double yuzde) | |
{ | |
return String.Format("{0:0.00}", tutar + Convert.ToDouble(tutar/100)*yuzde); | |
} | |
public static string YuzdelikCikarDegerDondur(double tutar, double yuzde) | |
{ | |
return String.Format("{0:0.00}", tutar + Convert.ToDouble(tutar / 100) * yuzde); | |
} | |
public static string YuzdelikCikarYuzdelikDondur(double tutar, double yuzde) | |
{ | |
return String.Format("{0:0.00}", Convert.ToDouble(tutar / 100) * yuzde); | |
} | |
public static string Yuzde5Cikar95Dondur(double tutar,double yuzde) | |
{ | |
return String.Format("{0:0.00}", Convert.ToDouble(tutar / 100) *(100- yuzde)); | |
} | |
public static string OndalıkKısmıAt(string Sayi) | |
{ | |
string sonuc = ""; | |
if (Sayi.Contains(",") || Sayi.Contains(".")) | |
{ | |
Sayi = Sayi.Replace(".", ","); | |
for (int i = 0; i < Sayi.Length; i++) | |
{ | |
if (Sayi[i].ToString() == ",") | |
{ | |
sonuc = Sayi.Remove(i); | |
break; | |
} | |
} | |
} | |
else | |
{ | |
sonuc = Sayi; | |
} | |
return sonuc; | |
} | |
public static class Kurlar | |
{ | |
public static string USDSatis { | |
get | |
{ | |
return glb.dataCell("select DovizSatis from kurlar where Id=(select max(Id) from kurlar where Kod='USD')").ToString(); | |
} | |
} | |
public static string EURSatis | |
{ | |
get | |
{ | |
return glb.dataCell("select DovizSatis from kurlar where Id=(select max(Id) from kurlar where Kod='EUR')").ToString(); | |
} | |
} | |
public static DataTable GuncelKurTablosu() | |
{ | |
DataTable dt = new DataTable(); | |
// DataTable nesnemizi yaratıyoruz | |
try | |
{ | |
DataRow dr; | |
// DataTable ın satırlarını tanımlıyoruz. | |
dt.Columns.Add(new DataColumn("Adı", typeof(string))); | |
dt.Columns.Add(new DataColumn("Kod", typeof(string))); | |
dt.Columns.Add(new DataColumn("DovizAlis", typeof(string))); | |
dt.Columns.Add(new DataColumn("DovizSatis", typeof(string))); | |
dt.Columns.Add(new DataColumn("EfektifAlis", typeof(string))); | |
dt.Columns.Add(new DataColumn("EfektifSatis", typeof(string))); | |
// DataTableımıza 6 sütün ekliyoruz ve değişken tiplerini tanımlıyoruz. | |
XmlTextReader rdr = new XmlTextReader("http://www.tcmb.gov.tr/kurlar/today.xml"); | |
// XmlTextReader nesnesini yaratıyoruz ve parametre olarak xml dokümanın urlsini veriyoruz | |
// XmlTextReader urlsi belirtilen xml dokümanlarına hızlı ve forward-only giriş imkanı sağlar. | |
XmlDocument myxml = new XmlDocument(); | |
// XmlDocument nesnesini yaratıyoruz. | |
myxml.Load(rdr); | |
// Load metodu ile xml yüklüyoruz | |
XmlNodeList adi = myxml.SelectNodes("/Tarih_Date/Currency/Isim"); | |
XmlNodeList kod = myxml.SelectNodes("/Tarih_Date/Currency/@Kod"); | |
XmlNodeList doviz_alis = myxml.SelectNodes("/Tarih_Date/Currency/ForexBuying"); | |
XmlNodeList doviz_satis = myxml.SelectNodes("/Tarih_Date/Currency/ForexSelling"); | |
XmlNodeList efektif_alis = myxml.SelectNodes("/Tarih_Date/Currency/BanknoteBuying"); | |
XmlNodeList efektif_satis = myxml.SelectNodes("/Tarih_Date/Currency/BanknoteSelling"); | |
// XmlNodeList cinsinden her bir nodu, SelectSingleNode metoduna nodların xpathini parametre olarak | |
// göndererek tanımlıyoruz. | |
// datagridimin captionu ayarlıyoruz. | |
int x = 17; | |
/* Burada xmlde bahsettiğim - bence- mantık hatasından dolayı x gibi bir değişken tanımladım. | |
bu x =19 DataTable a sadece 19 satır eklenmesini sağlıyor. çünkü xml dökümanında 19. node dan sonra | |
güncel kur bilgileri değil Euro dönüşüm kurları var ve bu node dan sonra yapı ilk 18 node ile tutmuyor | |
Bence ayrı bir xml dökümanda tutulması gerekirdi. | |
*/ | |
for (int i = 0; i < x; i++) | |
{ | |
dr = dt.NewRow(); | |
dr[0] = adi[i].InnerText.ToString(); // i. adi nodunun içeriği | |
// Adı isimli DataColumn un satırlarını /Tarih_Date/Currency/Isim node ları ile dolduruyoruz. | |
dr[1] = kod[i].InnerText.ToString(); | |
// Kod satırları | |
dr[2] = doviz_alis[i].InnerText.ToString(); | |
// Döviz Alış | |
dr[3] = doviz_satis[i].InnerText.ToString(); | |
// Döviz Satış | |
dr[4] = efektif_alis[i].InnerText.ToString(); | |
// Efektif Alış | |
dr[5] = efektif_satis[i].InnerText.ToString(); | |
// Efektif Satış. | |
dt.Rows.Add(dr); | |
} | |
} | |
catch (Exception ex) | |
{ | |
WebException a = new WebException(); | |
if (a.GetType() == ex.GetType()) | |
{ | |
a = (WebException)ex; | |
if (a.Status == WebExceptionStatus.NameResolutionFailure) | |
{ | |
MessageBox.Show("Eywah! www.tcmb.gov.tr adresine ulaşamıyorum.Bunun sebebi DNS ayarları olabilir veya internetiniz bulunmamaktadır.","Hata",MessageBoxButtons.OK,MessageBoxIcon.Error); | |
} | |
else | |
{ | |
MessageBox.Show("Eywah! bir bağlantı problemi oluştu ve www.tcmb.gov.tr adresine bağlanamıyorum.Lütfen internet ayarlarınızı kontrol ediniz!","Hata",MessageBoxButtons.OK,MessageBoxIcon.Error); | |
} | |
} | |
} | |
// DataTable ımızın satırlarını 18 satır olacak şekilde dolduruyoruz | |
// gerçi yine web mastırın insafı devreye giriyor:). | |
// yukarıda bahsettiğim sorun. | |
return dt; | |
// DataTable ı döndürüyoruz. | |
} | |
public static void voidKurlariGuncelle() | |
{ | |
DataTable kurlar = GuncelKurTablosu(); | |
for (int i = 0; i < kurlar.Rows.Count; i++) | |
{ | |
glb.executeQuery("insert into kurlar (Adi,Kod,DovizAlis,DovizSatis,EfektifAlis,EfektifSatis,Tarih) values('" + kurlar.Rows[i]["Adı"] + "','" + kurlar.Rows[i]["Kod"] + "','" + kurlar.Rows[i]["DovizAlis"] + "','" + kurlar.Rows[i]["DovizSatis"] + "','" + kurlar.Rows[i]["EfektifAlis"] + "','" + kurlar.Rows[i]["EfektifSatis"] + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "') "); | |
} | |
} | |
} | |
} | |
public static class MATEMATIK | |
{ | |
public static double OndalikSayili(object Deger, int OndalikSayi) | |
{ | |
string TamSayi = "0"; | |
string IcDeger = Deger.ToString(); | |
string ret = IcDeger; | |
IcDeger = IcDeger.ToString().Replace(",", "."); | |
for (int i = 0; i < IcDeger.Length; i++) | |
{ | |
if (IcDeger[i].ToString() == ".") | |
{ | |
TamSayi = IcDeger.Remove(i, IcDeger.Length - i); | |
if (IcDeger.Length - TamSayi.Length <= OndalikSayi) | |
{ | |
return Convert.ToDouble(Deger); | |
} | |
ret = IcDeger.Remove(TamSayi.Length + 1 + OndalikSayi, IcDeger.Length - (TamSayi.Length + 1 + OndalikSayi)); | |
if (OndalikSayi==0) | |
{ | |
ret = ret.Replace(".", ""); | |
} | |
break; | |
} | |
} | |
return Convert.ToDouble(ret.Replace(".",",")); | |
} | |
} | |
public static class Setup | |
{ | |
public static bool SetupDosyalariniSil() | |
{ | |
if (Directory.Exists(Environment.CurrentDirectory + @"\setup")) | |
{ | |
try | |
{ | |
Directory.Delete(Environment.CurrentDirectory + @"\setup", true); | |
} | |
catch | |
{ | |
return false; | |
} | |
} | |
return true; | |
} | |
public static void IniOlustur(string Path,string [] Satirlar) | |
{ | |
for (int i = 0; i < Satirlar.Length; i++) | |
{ | |
File.AppendAllText(Path, Satirlar[i]); | |
} | |
} | |
public static string ExecuteWaiting(string FileName, ProcessWindowStyle WindowStyle, string Parametre = "") | |
{ | |
try | |
{ | |
Process process = new Process | |
{ | |
StartInfo = { FileName = FileName, Arguments = Parametre, WindowStyle = WindowStyle } | |
}; | |
process.Start(); | |
process.WaitForExit(); | |
process.Close(); | |
return "İşlem Başarılı"; | |
} | |
catch (Exception exception) | |
{ | |
return exception.Message ; | |
} | |
} | |
} | |
public static class UTILITY | |
{ | |
public static string TurkceFormatIngilizce(string Yazi) | |
{ | |
return Yazi.Replace("ı", "i").Replace("ö", "o").Replace("Ö", "O").Replace("ü", "u").Replace("Ü", "U").Replace("ş", "s").Replace("Ş", "s").Replace("İ", "I").Replace("ç", "c").Replace("ğ", "g").Replace("Ğ", "g").Replace("Ç","C"); | |
} | |
//public static Bitmap Resize(Bitmap img) | |
//{ | |
// try | |
// { | |
// int width = 320; | |
// int height = 240; | |
// Bitmap image = new Bitmap(width, height); | |
// Graphics graphics = Graphics.FromImage(image); | |
// MemoryStream stream = new MemoryStream(); | |
// image.Save(stream, ImageFormat.Jpeg); | |
// graphics.DrawImage(img, 0, 0, width, height); | |
// graphics.Dispose(); | |
// ImageCodecInfo info = GetEncoder(ImageFormat.Jpeg); | |
// Encoder quality = Encoder.Quality; | |
// EncoderParameters encoderParams = new EncoderParameters(1); | |
// EncoderParameter parameter = new EncoderParameter(quality, 100L); | |
// encoderParams.Param[0] = parameter; | |
// image.Save(stream, info, encoderParams); | |
// return image; | |
// } | |
// catch (Exception) | |
// { | |
// return null; | |
// } | |
//} | |
public static bool TCKimlikKontrol(long TCKimlikNo) | |
{ | |
string str = TCKimlikNo.ToString(); | |
bool flag = str.Length == 11; | |
if (flag) | |
{ | |
byte num = (byte)(((byte)(((byte)(((byte)(Convert.ToByte(str.Substring(0, 1)) + Convert.ToByte(str.Substring(2, 1)))) + Convert.ToByte(str.Substring(4, 1)))) + Convert.ToByte(str.Substring(6, 1)))) + Convert.ToByte(str.Substring(8, 1))); | |
byte num2 = (byte)(((byte)(((byte)(Convert.ToByte(str.Substring(1, 1)) + Convert.ToByte(str.Substring(3, 1)))) + Convert.ToByte(str.Substring(5, 1)))) + Convert.ToByte(str.Substring(7, 1))); | |
short num3 = (short)((((num * 7) - num2) + 100) % 10); | |
byte num4 = (byte)(((short)(((byte)(((byte)(((byte)(((byte)(((byte)(((byte)(((byte)(((byte)(Convert.ToByte(str.Substring(0, 1)) + Convert.ToByte(str.Substring(1, 1)))) + Convert.ToByte(str.Substring(2, 1)))) + Convert.ToByte(str.Substring(3, 1)))) + Convert.ToByte(str.Substring(4, 1)))) + Convert.ToByte(str.Substring(5, 1)))) + Convert.ToByte(str.Substring(6, 1)))) + Convert.ToByte(str.Substring(7, 1)))) + Convert.ToByte(str.Substring(8, 1)))) + num3)) % 10); | |
flag = (num3.ToString() + num4.ToString()) == str.Substring(9, 2); | |
} | |
return flag; | |
} | |
public static int TarihKacGun(DateTime Tarih) | |
{ | |
int sonuc = 1; | |
DateTime GelenTarih = Convert.ToDateTime(Tarih.ToShortDateString()); | |
DateTime bugun = Convert.ToDateTime(DateTime.Now.ToShortDateString()); | |
for (int i = 0; i < sonuc; i++) | |
{ | |
if (DateTime.Compare(GelenTarih, bugun) == 0) | |
{ | |
break; | |
} | |
GelenTarih = TarihTopla(GelenTarih, 1); | |
sonuc++; | |
} | |
return sonuc - 1; | |
} | |
public static int TarihFarki(DateTime Tarih1, DateTime Tarih2) | |
{ | |
int sonuc = 1; | |
DateTime GelenTarih = Convert.ToDateTime(Tarih1.ToShortDateString()); | |
DateTime bugun = Convert.ToDateTime(Tarih2.ToShortDateString()); | |
if (bugun > Tarih1) | |
{ | |
for (int i = 0; i < sonuc; i++) | |
{ | |
if (DateTime.Compare(GelenTarih, bugun) == 0) | |
{ | |
break; | |
} | |
GelenTarih = TarihTopla(GelenTarih, 1); | |
sonuc++; | |
} | |
} | |
else if (bugun < Tarih1) | |
{ | |
for (int i = 0; i < sonuc; i++) | |
{ | |
if (DateTime.Compare(bugun, GelenTarih) == 0) | |
{ | |
break; | |
} | |
bugun = TarihTopla(bugun, 1); | |
sonuc++; | |
} | |
sonuc -= 2 * sonuc; | |
} | |
return sonuc - 1; | |
} | |
public static DateTime TarihTopla(DateTime dogum, int ekle) | |
{ | |
DateTime time = Convert.ToDateTime(dogum); | |
DateTime time2 = new DateTime(time.Year, time.Month, time.Day); | |
return time2.Date.AddDays((double)ekle); | |
} | |
public static int[] TARIHFARKI(DateTime TARIH1, DateTime TARIH2) | |
{ | |
DateTime time; | |
DateTime time2; | |
DateTime time3; | |
int[] numArray = new int[3]; | |
if (TARIH1 <= TARIH2) | |
{ | |
time = TARIH1; | |
time2 = TARIH2; | |
} | |
else | |
{ | |
time = TARIH2; | |
time2 = TARIH1; | |
} | |
if (((DateTime.IsLeapYear(time.Year) && !DateTime.IsLeapYear(time2.Year)) && (time.Month == 2)) && (time.Day == 0x1d)) | |
{ | |
time3 = new DateTime(time2.Year, time.Month, time.Day - 1); | |
} | |
else | |
{ | |
time3 = new DateTime(time2.Year, time.Month, time.Day); | |
} | |
numArray[2] = (time2.Year - time.Year) - ((time3 > time2) ? 1 : 0); | |
numArray[1] = (time2.Month - time.Month) + (12 * ((time3 > time2) ? 1 : 0)); | |
numArray[0] = time2.Day - time.Day; | |
if (numArray[0] < 0) | |
{ | |
if ((time2.Day == DateTime.DaysInMonth(time2.Year, time2.Month)) && ((time.Day >= DateTime.DaysInMonth(time2.Year, time2.Month)) || (time.Day >= DateTime.DaysInMonth(time2.Year, time.Month)))) | |
{ | |
numArray[0] = 0; | |
} | |
else | |
{ | |
numArray[1]--; | |
if ((DateTime.DaysInMonth(time2.Year, time2.Month) == DateTime.DaysInMonth(time.Year, time.Month)) && (time2.Month != time.Month)) | |
{ | |
int num = ((time2.Month - 1) > 0) ? DateTime.DaysInMonth(time2.Year, time2.Month - 1) : 0x1f; | |
numArray[0] = num + numArray[0]; | |
} | |
else | |
{ | |
numArray[0] = DateTime.DaysInMonth(time2.Year, (time2.Month == 1) ? 12 : (time2.Month - 1)) + numArray[0]; | |
} | |
} | |
} | |
string str = ""; | |
if (numArray[2] > 0) | |
{ | |
str = str + numArray[2] + " YIL "; | |
} | |
if (numArray[1] > 0) | |
{ | |
str = str + numArray[1] + " AY "; | |
} | |
if (numArray[0] > 0) | |
{ | |
str = str + numArray[0] + " G\x00dcN"; | |
} | |
return numArray; | |
} | |
internal class GunAyYilBul | |
{ | |
private DateTime dtAge; | |
private DateTime dtDob; | |
private DateTime dtNow; | |
private int intAgeDays; | |
private int intAgeHours; | |
private int intAgeMinutes; | |
private int intAgeMonths; | |
private int intAgeYear; | |
private int intDay; | |
private int intHour; | |
private int intMinute; | |
private int intMonth; | |
private int intYear; | |
private DateTime İşlemTarihi; | |
private TimeSpan tsAge; | |
public void createDateObjects() | |
{ | |
this.dtDob = new DateTime(this.intYear, this.intMonth, this.intDay, this.intHour, this.intMinute, 0); | |
this.dtNow = this.İşlemTarihi; | |
if (DateTime.Compare(this.dtNow, this.dtDob) == 1) | |
{ | |
this.tsAge = this.dtNow.Subtract(this.dtDob); | |
} | |
this.dtAge = new DateTime(this.tsAge.Ticks); | |
} | |
public int getAgeInDays() | |
{ | |
if (this.dtDob.Year == this.dtNow.Year) | |
{ | |
this.intAgeDays = this.dtNow.DayOfYear - this.dtDob.DayOfYear; | |
} | |
else | |
{ | |
if (DateTime.IsLeapYear(this.dtDob.Year)) | |
{ | |
this.intAgeDays = 0x16e - this.dtDob.DayOfYear; | |
} | |
else | |
{ | |
this.intAgeDays = 0x16d - this.dtDob.DayOfYear; | |
} | |
for (int i = this.dtDob.Year + 1; i < this.dtNow.Year; i++) | |
{ | |
if (DateTime.IsLeapYear(i)) | |
{ | |
this.intAgeDays += 0x16e; | |
} | |
else | |
{ | |
this.intAgeDays += 0x16d; | |
} | |
} | |
this.intAgeDays += this.dtNow.DayOfYear; | |
} | |
return this.intAgeDays; | |
} | |
public int getAgeInHours() | |
{ | |
this.intAgeHours = this.getAgeInDays() * 0x18; | |
this.intAgeHours += this.dtNow.Hour - this.dtDob.Hour; | |
return this.intAgeHours; | |
} | |
public int getAgeInMinutes() | |
{ | |
this.intAgeMinutes = this.getAgeInHours() * 60; | |
this.intAgeMinutes += this.dtNow.Minute - this.dtDob.Minute; | |
return this.intAgeMinutes; | |
} | |
public int getAgeInMonths() | |
{ | |
this.intAgeMonths = this.intAgeYear * 12; | |
if (((this.İşlemTarihi.Year >= this.intYear) && (this.intMonth == this.İşlemTarihi.Month)) && (this.intDay > this.İşlemTarihi.Day)) | |
{ | |
this.intAgeMonths += this.dtAge.Month; | |
} | |
else | |
{ | |
this.intAgeMonths += this.dtAge.Month - 1; | |
} | |
return this.intAgeMonths; | |
} | |
public int getAgeInYears() | |
{ | |
this.intAgeYear = this.dtAge.Year - 1; | |
this.getAgeInMonths(); | |
this.getAgeInDays(); | |
return this.intAgeYear; | |
} | |
public int getDayDiff() | |
{ | |
int year; | |
int month; | |
int num = this.getAgeInDays(); | |
int intDay = this.intDay; | |
if (this.dtNow.Year != this.dtDob.Year) | |
{ | |
if (1 == this.dtNow.Month) | |
{ | |
year = this.dtNow.Year - 1; | |
month = 12; | |
} | |
else | |
{ | |
if (this.dtNow.Day < intDay) | |
{ | |
month = this.dtNow.Month - 1; | |
} | |
else | |
{ | |
month = this.dtNow.Month; | |
intDay = 1; | |
} | |
year = this.dtNow.Year; | |
} | |
} | |
else | |
{ | |
if ((1 == this.dtNow.Month) || (this.dtDob.Month == this.dtNow.Month)) | |
{ | |
return this.getAgeInDays(); | |
} | |
if (this.dtNow.Day < intDay) | |
{ | |
month = this.dtNow.Month - 1; | |
} | |
else | |
{ | |
month = this.dtNow.Month; | |
intDay = 1; | |
} | |
year = this.intYear; | |
} | |
this.dtNow = new DateTime(year, month, this.intDay); | |
int num2 = this.getAgeInDays(); | |
return (num - num2); | |
} | |
public void getDob(DateTime DogumTarihi, DateTime Tarih) | |
{ | |
this.İşlemTarihi = Tarih; | |
this.intDay = DogumTarihi.Day; | |
this.intMonth = DogumTarihi.Month; | |
this.intYear = DogumTarihi.Year; | |
this.intHour = 0; | |
this.intMinute = 0; | |
} | |
public int getMonthDiff() | |
{ | |
return (this.getAgeInMonths() % 12); | |
} | |
} | |
public static double TarihCevir(TarihCeviriTur CevirilecekTur,int CevirilecekMiktar,TarihCeviriTur SonucTur) | |
{ | |
///Tamamlanmamıs metot | |
double sonuc = -1; | |
if (CevirilecekTur==TarihCeviriTur.Dakika) | |
{ | |
if (SonucTur==TarihCeviriTur.Saat) | |
{ | |
sonuc = CevirilecekMiktar / 60; | |
} | |
if (SonucTur==TarihCeviriTur.Gun) | |
{ | |
} | |
} | |
if (SonucTur == TarihCeviriTur.Dakika) | |
{ | |
} | |
return sonuc; | |
} | |
public enum TarihCeviriTur | |
{ | |
Dakika, | |
Saat, | |
Gun, | |
Ay, | |
Yil, | |
} | |
public static string YasHesapla(DateTime DogumTarihi) | |
{ | |
int [] YasArray=TARIHFARKI(DogumTarihi,DateTime.Now); | |
return (YasArray[2].ToString() + " Yaş " + YasArray[1].ToString() + " Ay " + YasArray[0].ToString() + " Gün"); | |
} | |
//public static double Ondalik2Sıfırlı(string Deger) | |
//{ | |
// double sonuc = -1; | |
// string ondalik =""; | |
// string tamsayi=""; | |
// for (int i = 0; i < Deger.Length; i++) | |
// { | |
// if (Deger[i].ToString()==","||Deger[i].ToString()==".") | |
// { | |
// if (Deger.Remove(0,i).Length>2) | |
// { | |
// for (int j = 1; j < 3; j++) | |
// { | |
// ondalik += Deger[i + j].ToString(); | |
// } | |
// } | |
// else | |
// { | |
// if (Deger.Remove(0, i).Contains(",")||Deger.Remove(0,i).Contains(".")) | |
// { | |
// ondalik = Deger.Remove(0, i).Replace(",", "").Replace(".", ""); ; | |
// } | |
// else | |
// { | |
// ondalik = Deger.Remove(0, i); ; | |
// } | |
// } | |
// break; | |
// } | |
// else | |
// { | |
// tamsayi += Deger[i].ToString(); | |
// } | |
// } | |
// sonuc = double.Parse(tamsayi + "." + ondalik); | |
// return sonuc; | |
//} | |
public static double OndalikSayiliSıfırlı(string Deger,int OndalikSayisi) | |
{ | |
//Tamamlanmamış fonksiyon | |
double sonuc = -1; | |
string ondalik = ""; | |
string tamsayi = ""; | |
for (int i = 0; i < Deger.Length; i++) | |
{ | |
if (Deger[i].ToString() == "," || Deger[i].ToString() == ".") | |
{ | |
if (Deger.Remove(0, i).Length > 2) | |
{ | |
for (int j = 1; j < 3; j++) | |
{ | |
ondalik += Deger[i + j].ToString(); | |
} | |
} | |
else | |
{ | |
if (Deger.Remove(0, i).Contains(",") || Deger.Remove(0, i).Contains(".")) | |
{ | |
ondalik = Deger.Remove(0, i).Replace(",", "").Replace(".", ""); ; | |
} | |
else | |
{ | |
ondalik = Deger.Remove(0, i); ; | |
} | |
} | |
break; | |
} | |
else | |
{ | |
tamsayi += Deger[i].ToString(); | |
} | |
} | |
sonuc = double.Parse(tamsayi + "." + ondalik); | |
return sonuc; | |
} | |
public static string MetinBelgesindeSatirDegistir(string BelgeYolu, int SatırNumarası, string YeniYazı) | |
{ | |
string sonuc = ""; | |
if (File.Exists(BelgeYolu)) | |
{ | |
try | |
{ | |
string[] dosya = File.ReadAllLines(BelgeYolu); | |
File.Delete(BelgeYolu); | |
for (int i = 0; i < dosya.Length; i++) | |
{ | |
if (i != SatırNumarası-1) | |
{ | |
File.AppendAllText(BelgeYolu, dosya[i].ToString()); | |
} | |
else if (i == SatırNumarası-1) | |
{ | |
File.AppendAllText(BelgeYolu, YeniYazı); | |
} | |
File.AppendAllText(BelgeYolu, Environment.NewLine); | |
} | |
sonuc = "İşlem Başarılı."; | |
} | |
catch (Exception ex) | |
{ | |
sonuc = ex.Message; | |
} | |
} | |
else | |
{ | |
sonuc = "Dosya yok veya silinmiş."; | |
} | |
return sonuc; | |
} | |
public static byte[] imageToByteArray(System.Drawing.Image imageIn) | |
{ | |
try | |
{ | |
MemoryStream stream = new MemoryStream(); | |
imageIn.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); | |
return stream.ToArray(); | |
} | |
catch | |
{ | |
return null; | |
} | |
} | |
public static bool Sayımı(object Deger) | |
{ | |
return Microsoft.VisualBasic.Information.IsNumeric(Deger); | |
} | |
public static void killProcess(string processName) | |
{ | |
foreach (Process p in System.Diagnostics.Process.GetProcessesByName(processName)) | |
{ | |
try | |
{ | |
p.Kill(); | |
p.WaitForExit(); // possibly with a timeout | |
} | |
catch | |
{ | |
// process was terminating or can't be terminated - deal with it | |
} | |
} | |
} | |
public static string [] EbatAyir(string Ebat) | |
{ | |
string[] sonuc = new string[2]; | |
for (int i = 0; i < Ebat.Length; i++) | |
{ | |
if (Ebat[i].ToString() == "x" || Ebat[i].ToString() == "X"|| Ebat[i].ToString() == "*") | |
{ | |
sonuc[0] = Ebat.Remove(i); | |
sonuc[1] = Ebat.Replace(sonuc[0], "").Replace("x","").Replace("X","").Replace("*",""); | |
break; | |
} | |
} | |
return sonuc; | |
} | |
public static class NETWORK | |
{ | |
//İnternet bağlantısı varmı yokmu | |
[System.Runtime.InteropServices.DllImport("wininet.dll")] | |
private static extern bool InternetGetConnectedState(out int Description, int ReservedValue); | |
public static bool IsConnectedToInternet() | |
{ | |
int num; | |
return InternetGetConnectedState(out num, 0); | |
} | |
//Bilgisayarın internetteki Ip Adresi | |
public static string voidInternetIp() | |
{ | |
string sonuc = ""; | |
try | |
{ | |
string url = "http://www.prodigyproductionsllc.com/yourip.php"; | |
System.Net.WebClient wc = new System.Net.WebClient(); | |
try | |
{ | |
sonuc = wc.DownloadString(url).ToString(); | |
} | |
catch (Exception ex) | |
{ | |
sonuc = ex.Message; | |
} | |
} | |
catch (Exception ex) | |
{ | |
sonuc = ex.Message; | |
} | |
File.Delete(Environment.CurrentDirectory + @"\IPStoraged.ini"); | |
File.AppendAllText(Environment.CurrentDirectory + @"\IPStoraged.ini", DateTime.Now.Day.ToString()); | |
return sonuc; | |
} | |
//Tüm Gelişmiş FTP İşlemlerinin Yapıldığı Class | |
public sealed class FTP | |
{ | |
#region "FTP client class" | |
/// <summary> | |
/// A wrapper class for .NET 2.0 FTP | |
/// </summary> | |
/// <remarks> | |
/// This class does not hold open an FTP connection but | |
/// instead is stateless: for each FTP request it | |
/// connects, performs the request and disconnects. | |
/// </remarks> | |
public class FTPclient | |
{ | |
#region "CONSTRUCTORS" | |
/// <summary> | |
/// Blank constructor | |
/// </summary> | |
/// <remarks>Hostname, username and password must be set manually</remarks> | |
public FTPclient() | |
{ | |
} | |
/// <summary> | |
/// Constructor just taking the hostname | |
/// </summary> | |
/// <param name="Hostname">in either ftp://ftp.host.com or ftp.host.com form</param> | |
/// <remarks></remarks> | |
public FTPclient(string Hostname) | |
{ | |
_hostname = Hostname; | |
} | |
/// <summary> | |
/// Constructor taking hostname, username and password | |
/// </summary> | |
/// <param name="Hostname">in either ftp://ftp.host.com or ftp.host.com form</param> | |
/// <param name="Username">Leave blank to use 'anonymous' but set password to your email</param> | |
/// <param name="Password"></param> | |
/// <remarks></remarks> | |
public FTPclient(string Hostname, string Username, string Password) | |
{ | |
_hostname = Hostname; | |
_username = Username; | |
_password = Password; | |
} | |
#endregion | |
#region "Directory functions" | |
/// <summary> | |
/// Return a simple directory listing | |
/// </summary> | |
/// <param name="directory">Directory to list, e.g. /pub</param> | |
/// <returns>A list of filenames and directories as a List(of String)</returns> | |
/// <remarks>For a detailed directory listing, use ListDirectoryDetail</remarks> | |
public List<string> ListDirectory(string directory) | |
{ | |
//return a simple list of filenames in directory | |
System.Net.FtpWebRequest ftp = GetRequest(GetDirectory(directory)); | |
//Set request to do simple list | |
ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectory; | |
string str = GetStringResponse(ftp); | |
//replace CRLF to CR, remove last instance | |
str = str.Replace("\r\n", "\r").TrimEnd('\r'); | |
//split the string into a list | |
List<string> result = new List<string>(); | |
result.AddRange(str.Split('\r')); | |
return result; | |
} | |
/// <summary> | |
/// Return a detailed directory listing | |
/// </summary> | |
/// <param name="directory">Directory to list, e.g. /pub/etc</param> | |
/// <returns>An FTPDirectory object</returns> | |
public FTPdirectory ListDirectoryDetail(string directory) | |
{ | |
System.Net.FtpWebRequest ftp = GetRequest(GetDirectory(directory)); | |
//Set request to do simple list | |
ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails; | |
string str = GetStringResponse(ftp); | |
//replace CRLF to CR, remove last instance | |
str = str.Replace("\r\n", "\r").TrimEnd('\r'); | |
//split the string into a list | |
return new FTPdirectory(str, _lastDirectory); | |
} | |
#endregion | |
#region "Upload: File transfer TO ftp server" | |
/// <summary> | |
/// Copy a local file to the FTP server | |
/// </summary> | |
/// <param name="localFilename">Full path of the local file</param> | |
/// <param name="targetFilename">Target filename, if required</param> | |
/// <returns></returns> | |
/// <remarks>If the target filename is blank, the source filename is used | |
/// (assumes current directory). Otherwise use a filename to specify a name | |
/// or a full path and filename if required.</remarks> | |
public bool Upload(string localFilename, string targetFilename) | |
{ | |
//1. check source | |
if (!File.Exists(localFilename)) | |
{ | |
throw (new ApplicationException("File " + localFilename + " not found")); | |
} | |
//copy to FI | |
FileInfo fi = new FileInfo(localFilename); | |
return Upload(fi, targetFilename); | |
} | |
/// <summary> | |
/// Upload a local file to the FTP server | |
/// </summary> | |
/// <param name="fi">Source file</param> | |
/// <param name="targetFilename">Target filename (optional)</param> | |
/// <returns></returns> | |
public bool Upload(FileInfo fi, string targetFilename) | |
{ | |
//copy the file specified to target file: target file can be full path or just filename (uses current dir) | |
//1. check target | |
string target; | |
if (string.IsNullOrEmpty( targetFilename)) | |
{ | |
//Blank target: use source filename & current dir | |
target = this.CurrentDirectory + fi.Name; | |
} | |
else if (targetFilename.Contains("/")) | |
{ | |
//If contains / treat as a full path | |
target = AdjustDir(targetFilename); | |
} | |
else | |
{ | |
//otherwise treat as filename only, use current directory | |
target = CurrentDirectory + targetFilename; | |
} | |
string URI = Hostname + target; | |
//perform copy | |
System.Net.FtpWebRequest ftp = GetRequest(URI); | |
//Set request to upload a file in binary | |
ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile; | |
ftp.UseBinary = true; | |
//Notify FTP of the expected size | |
ftp.ContentLength = fi.Length; | |
//create byte array to store: ensure at least 1 byte! | |
const int BufferSize = 2048; | |
byte[] content = new byte[BufferSize - 1 + 1]; | |
int dataRead; | |
//open file for reading | |
using (FileStream fs = fi.OpenRead()) | |
{ | |
try | |
{ | |
//open request to send | |
using (Stream rs = ftp.GetRequestStream()) | |
{ | |
do | |
{ | |
dataRead = fs.Read(content, 0, BufferSize); | |
rs.Write(content, 0, dataRead); | |
} while (!(dataRead < BufferSize)); | |
rs.Close(); | |
} | |
} | |
catch (Exception) | |
{ | |
} | |
finally | |
{ | |
//ensure file closed | |
fs.Close(); | |
} | |
} | |
ftp = null; | |
return true; | |
} | |
#endregion | |
#region "Download: File transfer FROM ftp server" | |
/// <summary> | |
/// Copy a file from FTP server to local | |
/// </summary> | |
/// <param name="sourceFilename">Target filename, if required</param> | |
/// <param name="localFilename">Full path of the local file</param> | |
/// <returns></returns> | |
/// <remarks>Target can be blank (use same filename), or just a filename | |
/// (assumes current directory) or a full path and filename</remarks> | |
public bool Download(string sourceFilename, string localFilename, bool PermitOverwrite) | |
{ | |
//2. determine target file | |
FileInfo fi = new FileInfo(localFilename); | |
return this.Download(sourceFilename, fi, PermitOverwrite); | |
} | |
//Version taking an FtpFileInfo | |
public bool Download(FTPfileInfo file, string localFilename, bool PermitOverwrite) | |
{ | |
return this.Download(file.FullName, localFilename, PermitOverwrite); | |
} | |
//Another version taking FtpFileInfo and FileInfo | |
public bool Download(FTPfileInfo file, FileInfo localFI, bool PermitOverwrite) | |
{ | |
return this.Download(file.FullName, localFI, PermitOverwrite); | |
} | |
//Version taking string/FileInfo | |
public bool Download(string sourceFilename, FileInfo targetFI, bool PermitOverwrite) | |
{ | |
//1. check target | |
if (targetFI.Exists && !(PermitOverwrite)) | |
{ | |
throw (new ApplicationException("Target file already exists")); | |
} | |
//2. check source | |
string target; | |
if (string.IsNullOrEmpty( sourceFilename.Trim())) | |
{ | |
throw (new ApplicationException("File not specified")); | |
} | |
else if (sourceFilename.Contains("/")) | |
{ | |
//treat as a full path | |
target = AdjustDir(sourceFilename); | |
} | |
else | |
{ | |
//treat as filename only, use current directory | |
target = CurrentDirectory + sourceFilename; | |
} | |
string URI = Hostname + target; | |
//3. perform copy | |
System.Net.FtpWebRequest ftp = GetRequest(URI); | |
//Set request to download a file in binary mode | |
ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile; | |
ftp.UseBinary = true; | |
//open request and get response stream | |
using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse()) | |
{ | |
using (Stream responseStream = response.GetResponseStream()) | |
{ | |
//loop to read & write to file | |
using (FileStream fs = targetFI.OpenWrite()) | |
{ | |
try | |
{ | |
byte[] buffer = new byte[2048]; | |
int read = 0; | |
do | |
{ | |
read = responseStream.Read(buffer, 0, buffer.Length); | |
fs.Write(buffer, 0, read); | |
} while (!(read == 0)); | |
responseStream.Close(); | |
fs.Flush(); | |
fs.Close(); | |
} | |
catch (Exception) | |
{ | |
//catch error and delete file only partially downloaded | |
fs.Close(); | |
//delete target file as it's incomplete | |
targetFI.Delete(); | |
throw; | |
} | |
} | |
responseStream.Close(); | |
} | |
response.Close(); | |
} | |
return true; | |
} | |
#endregion | |
#region "Other functions: Delete rename etc." | |
/// <summary> | |
/// Delete remote file | |
/// </summary> | |
/// <param name="filename">filename or full path</param> | |
/// <returns></returns> | |
/// <remarks></remarks> | |
public bool FtpDelete(string filename) | |
{ | |
//Determine if file or full path | |
string URI = this.Hostname + GetFullPath(filename); | |
System.Net.FtpWebRequest ftp = GetRequest(URI); | |
//Set request to delete | |
ftp.Method = System.Net.WebRequestMethods.Ftp.DeleteFile; | |
try | |
{ | |
//get response but ignore it | |
GetStringResponse(ftp); | |
} | |
catch (Exception) | |
{ | |
return false; | |
} | |
return true; | |
} | |
/// <summary> | |
/// Determine if file exists on remote FTP site | |
/// </summary> | |
/// <param name="filename">Filename (for current dir) or full path</param> | |
/// <returns></returns> | |
/// <remarks>Note this only works for files</remarks> | |
public bool FtpFileExists(string filename) | |
{ | |
//Try to obtain filesize: if we get error msg containing "550" | |
//the file does not exist | |
try | |
{ | |
GetFileSize(filename); | |
return true; | |
} | |
catch (Exception ex) | |
{ | |
//only handle expected not-found exception | |
if (ex is System.Net.WebException) | |
{ | |
//file does not exist/no rights error = 550 | |
if (ex.Message.Contains("550")) | |
{ | |
//clear | |
return false; | |
} | |
else | |
{ | |
throw; | |
} | |
} | |
else | |
{ | |
throw; | |
} | |
} | |
} | |
/// <summary> | |
/// Determine size of remote file | |
/// </summary> | |
/// <param name="filename"></param> | |
/// <returns></returns> | |
/// <remarks>Throws an exception if file does not exist</remarks> | |
public long GetFileSize(string filename) | |
{ | |
string path; | |
if (filename.Contains("/")) | |
{ | |
path = AdjustDir(filename); | |
} | |
else | |
{ | |
path = this.CurrentDirectory + filename; | |
} | |
string URI = this.Hostname + path; | |
System.Net.FtpWebRequest ftp = GetRequest(URI); | |
//Try to get info on file/dir? | |
ftp.Method = System.Net.WebRequestMethods.Ftp.GetFileSize; | |
return GetSize(ftp); | |
} | |
public bool FtpRename(string sourceFilename, string newName) | |
{ | |
//Does file exist? | |
string source = GetFullPath(sourceFilename); | |
if (!FtpFileExists(source)) | |
{ | |
throw (new FileNotFoundException("File " + source + " not found")); | |
} | |
//build target name, ensure it does not exist | |
string target = GetFullPath(newName); | |
if (target == source) | |
{ | |
throw (new ApplicationException("Source and target are the same")); | |
} | |
else if (FtpFileExists(target)) | |
{ | |
throw (new ApplicationException("Target file " + target + " already exists")); | |
} | |
//perform rename | |
string URI = this.Hostname + source; | |
System.Net.FtpWebRequest ftp = GetRequest(URI); | |
//Set request to delete | |
ftp.Method = System.Net.WebRequestMethods.Ftp.Rename; | |
ftp.RenameTo = target; | |
try | |
{ | |
//get response but ignore it | |
GetStringResponse(ftp); | |
} | |
catch | |
{ | |
return false; | |
} | |
return true; | |
} | |
public bool FtpCreateDirectory(string dirpath) | |
{ | |
//perform create | |
string URI = this.Hostname + AdjustDir(dirpath); | |
System.Net.FtpWebRequest ftp = GetRequest(URI); | |
//Set request to MkDir | |
ftp.Method = System.Net.WebRequestMethods.Ftp.MakeDirectory; | |
try | |
{ | |
//get response but ignore it | |
GetStringResponse(ftp); | |
} | |
catch (Exception) | |
{ | |
return false; | |
} | |
return true; | |
} | |
public bool FtpDeleteDirectory(string dirpath) | |
{ | |
//perform remove | |
string URI = this.Hostname + AdjustDir(dirpath); | |
System.Net.FtpWebRequest ftp = GetRequest(URI); | |
//Set request to RmDir | |
ftp.Method = System.Net.WebRequestMethods.Ftp.RemoveDirectory; | |
try | |
{ | |
//get response but ignore it | |
GetStringResponse(ftp); | |
} | |
catch (Exception) | |
{ | |
return false; | |
} | |
return true; | |
} | |
#endregion | |
#region "private supporting fns" | |
//Get the basic FtpWebRequest object with the | |
//common settings and security | |
private FtpWebRequest GetRequest(string URI) | |
{ | |
//create request | |
FtpWebRequest result = (FtpWebRequest)FtpWebRequest.Create(URI); | |
//Set the login details | |
result.Credentials = GetCredentials(); | |
//Do not keep alive (stateless mode) | |
result.KeepAlive = false; | |
return result; | |
} | |
/// <summary> | |
/// Get the credentials from username/password | |
/// </summary> | |
private System.Net.ICredentials GetCredentials() | |
{ | |
return new System.Net.NetworkCredential(Username, Password); | |
} | |
/// <summary> | |
/// returns a full path using CurrentDirectory for a relative file reference | |
/// </summary> | |
private string GetFullPath(string file) | |
{ | |
if (file.Contains("/")) | |
{ | |
return AdjustDir(file); | |
} | |
else | |
{ | |
return this.CurrentDirectory + file; | |
} | |
} | |
/// <summary> | |
/// Amend an FTP path so that it always starts with / | |
/// </summary> | |
/// <param name="path">Path to adjust</param> | |
/// <returns></returns> | |
/// <remarks></remarks> | |
private string AdjustDir(string path) | |
{ | |
return ((path.StartsWith("/")) ? "" : "/").ToString() + path; | |
} | |
private string GetDirectory(string directory) | |
{ | |
string URI; | |
if (string.IsNullOrEmpty( directory)) | |
{ | |
//build from current | |
URI = Hostname + this.CurrentDirectory; | |
_lastDirectory = this.CurrentDirectory; | |
} | |
else | |
{ | |
if (!directory.StartsWith("/")) | |
{ | |
throw (new ApplicationException("Directory should start with /")); | |
} | |
URI = this.Hostname + directory; | |
_lastDirectory = directory; | |
} | |
return URI; | |
} | |
//stores last retrieved/set directory | |
private string _lastDirectory = ""; | |
/// <summary> | |
/// Obtains a response stream as a string | |
/// </summary> | |
/// <param name="ftp">current FTP request</param> | |
/// <returns>String containing response</returns> | |
/// <remarks>FTP servers typically return strings with CR and | |
/// not CRLF. Use respons.Replace(vbCR, vbCRLF) to convert | |
/// to an MSDOS string</remarks> | |
private string GetStringResponse(FtpWebRequest ftp) | |
{ | |
//Get the result, streaming to a string | |
string result = ""; | |
using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse()) | |
{ | |
using (Stream datastream = response.GetResponseStream()) | |
{ | |
using (StreamReader sr = new StreamReader(datastream)) | |
{ | |
result = sr.ReadToEnd(); | |
sr.Close(); | |
} | |
datastream.Close(); | |
} | |
response.Close(); | |
} | |
return result; | |
} | |
/// <summary> | |
/// Gets the size of an FTP request | |
/// </summary> | |
/// <param name="ftp"></param> | |
/// <returns></returns> | |
/// <remarks></remarks> | |
private long GetSize(FtpWebRequest ftp) | |
{ | |
long size; | |
using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse()) | |
{ | |
size = response.ContentLength; | |
response.Close(); | |
} | |
return size; | |
} | |
#endregion | |
#region "Properties" | |
private string _hostname; | |
/// <summary> | |
/// Hostname | |
/// </summary> | |
/// <value></value> | |
/// <remarks>Hostname can be in either the full URL format | |
/// ftp://ftp.myhost.com or just ftp.myhost.com | |
/// </remarks> | |
public string Hostname | |
{ | |
get | |
{ | |
if (_hostname.StartsWith("ftp://")) | |
{ | |
return _hostname; | |
} | |
else | |
{ | |
return "ftp://" + _hostname; | |
} | |
} | |
set | |
{ | |
_hostname = value; | |
} | |
} | |
private string _username; | |
/// <summary> | |
/// Username property | |
/// </summary> | |
/// <value></value> | |
/// <remarks>Can be left blank, in which case 'anonymous' is returned</remarks> | |
public string Username | |
{ | |
get | |
{ | |
return (string.IsNullOrEmpty(_username )? "anonymous" : _username); | |
} | |
set | |
{ | |
_username = value; | |
} | |
} | |
private string _password; | |
public string Password | |
{ | |
get | |
{ | |
return _password; | |
} | |
set | |
{ | |
_password = value; | |
} | |
} | |
/// <summary> | |
/// The CurrentDirectory value | |
/// </summary> | |
/// <remarks>Defaults to the root '/'</remarks> | |
private string _currentDirectory = "/"; | |
public string CurrentDirectory | |
{ | |
get | |
{ | |
//return directory, ensure it ends with / | |
return _currentDirectory + ((_currentDirectory.EndsWith("/")) ? "" : "/").ToString(); | |
} | |
set | |
{ | |
if (!value.StartsWith("/")) | |
{ | |
throw (new ApplicationException("Directory should start with /")); | |
} | |
_currentDirectory = value; | |
} | |
} | |
#endregion | |
} | |
#endregion | |
#region "FTP file info class" | |
/// <summary> | |
/// Represents a file or directory entry from an FTP listing | |
/// </summary> | |
/// <remarks> | |
/// This class is used to parse the results from a detailed | |
/// directory list from FTP. It supports most formats of | |
/// </remarks> | |
public class FTPfileInfo | |
{ | |
//Stores extended info about FTP file | |
#region "Properties" | |
public string FullName | |
{ | |
get | |
{ | |
return Path + Filename; | |
} | |
} | |
public string Filename | |
{ | |
get | |
{ | |
return _filename; | |
} | |
} | |
public string Path | |
{ | |
get | |
{ | |
return _path; | |
} | |
} | |
public DirectoryEntryTypes FileType | |
{ | |
get | |
{ | |
return _fileType; | |
} | |
} | |
public long Size | |
{ | |
get | |
{ | |
return _size; | |
} | |
} | |
public DateTime FileDateTime | |
{ | |
get | |
{ | |
return _fileDateTime; | |
} | |
} | |
public string Permission | |
{ | |
get | |
{ | |
return _permission; | |
} | |
} | |
public string Extension | |
{ | |
get | |
{ | |
int i = this.Filename.LastIndexOf("."); | |
if (i >= 0 && i < (this.Filename.Length - 1)) | |
{ | |
return this.Filename.Substring(i + 1); | |
} | |
else | |
{ | |
return ""; | |
} | |
} | |
} | |
public string NameOnly | |
{ | |
get | |
{ | |
int i = this.Filename.LastIndexOf("."); | |
if (i > 0) | |
{ | |
return this.Filename.Substring(0, i); | |
} | |
else | |
{ | |
return this.Filename; | |
} | |
} | |
} | |
private string _filename; | |
private string _path; | |
private DirectoryEntryTypes _fileType; | |
private long _size; | |
private DateTime _fileDateTime; | |
private string _permission; | |
#endregion | |
/// <summary> | |
/// Identifies entry as either File or Directory | |
/// </summary> | |
public enum DirectoryEntryTypes | |
{ | |
File, | |
Directory | |
} | |
/// <summary> | |
/// Constructor taking a directory listing line and path | |
/// </summary> | |
/// <param name="line">The line returned from the detailed directory list</param> | |
/// <param name="path">Path of the directory</param> | |
/// <remarks></remarks> | |
public FTPfileInfo(string line, string path) | |
{ | |
//parse line | |
Match m = GetMatchingRegex(line); | |
if (m == null) | |
{ | |
//failed | |
throw (new ApplicationException("Unable to parse line: " + line)); | |
} | |
else | |
{ | |
_filename = m.Groups["name"].Value; | |
_path = path; | |
Int64.TryParse(m.Groups["size"].Value, out _size); | |
//_size = System.Convert.ToInt32(m.Groups["size"].Value); | |
_permission = m.Groups["permission"].Value; | |
string _dir = m.Groups["dir"].Value; | |
if (!string.IsNullOrEmpty( _dir) && _dir != "-") | |
{ | |
_fileType = DirectoryEntryTypes.Directory; | |
} | |
else | |
{ | |
_fileType = DirectoryEntryTypes.File; | |
} | |
try | |
{ | |
_fileDateTime = DateTime.Parse(m.Groups["timestamp"].Value); | |
} | |
catch (Exception) | |
{ | |
_fileDateTime = Convert.ToDateTime(null); | |
} | |
} | |
} | |
private Match GetMatchingRegex(string line) | |
{ | |
Regex rx; | |
Match m; | |
for (int i = 0; i <= _ParseFormats.Length - 1; i++) | |
{ | |
rx = new Regex(_ParseFormats[i]); | |
m = rx.Match(line); | |
if (m.Success) | |
{ | |
return m; | |
} | |
} | |
return null; | |
} | |
#region "Regular expressions for parsing LIST results" | |
/// <summary> | |
/// List of REGEX formats for different FTP server listing formats | |
/// </summary> | |
/// <remarks> | |
/// The first three are various UNIX/LINUX formats, fourth is for MS FTP | |
/// in detailed mode and the last for MS FTP in 'DOS' mode. | |
/// I wish VB.NET had support for Const arrays like C# but there you go | |
/// </remarks> | |
private static string[] _ParseFormats = new string[] { | |
"(?<dir>[\\-d])(?<permission>([\\-r][\\-w][\\-xs]){3})\\s+\\d+\\s+\\w+\\s+\\w+\\s+(?<size>\\d+)\\s+(?<timestamp>\\w+\\s+\\d+\\s+\\d{4})\\s+(?<name>.+)", | |
"(?<dir>[\\-d])(?<permission>([\\-r][\\-w][\\-xs]){3})\\s+\\d+\\s+\\d+\\s+(?<size>\\d+)\\s+(?<timestamp>\\w+\\s+\\d+\\s+\\d{4})\\s+(?<name>.+)", | |
"(?<dir>[\\-d])(?<permission>([\\-r][\\-w][\\-xs]){3})\\s+\\d+\\s+\\d+\\s+(?<size>\\d+)\\s+(?<timestamp>\\w+\\s+\\d+\\s+\\d{1,2}:\\d{2})\\s+(?<name>.+)", | |
"(?<dir>[\\-d])(?<permission>([\\-r][\\-w][\\-xs]){3})\\s+\\d+\\s+\\w+\\s+\\w+\\s+(?<size>\\d+)\\s+(?<timestamp>\\w+\\s+\\d+\\s+\\d{1,2}:\\d{2})\\s+(?<name>.+)", | |
"(?<dir>[\\-d])(?<permission>([\\-r][\\-w][\\-xs]){3})(\\s+)(?<size>(\\d+))(\\s+)(?<ctbit>(\\w+\\s\\w+))(\\s+)(?<size2>(\\d+))\\s+(?<timestamp>\\w+\\s+\\d+\\s+\\d{2}:\\d{2})\\s+(?<name>.+)", | |
"(?<timestamp>\\d{2}\\-\\d{2}\\-\\d{2}\\s+\\d{2}:\\d{2}[Aa|Pp][mM])\\s+(?<dir>\\<\\w+\\>){0,1}(?<size>\\d+){0,1}\\s+(?<name>.+)" }; | |
#endregion | |
} | |
#endregion | |
#region "FTP Directory class" | |
/// <summary> | |
/// Stores a list of files and directories from an FTP result | |
/// </summary> | |
/// <remarks></remarks> | |
public class FTPdirectory : List<FTPfileInfo> | |
{ | |
public FTPdirectory() | |
{ | |
//creates a blank directory listing | |
} | |
/// <summary> | |
/// Constructor: create list from a (detailed) directory string | |
/// </summary> | |
/// <param name="dir">directory listing string</param> | |
/// <param name="path"></param> | |
/// <remarks></remarks> | |
public FTPdirectory(string dir, string path) | |
{ | |
foreach (string line in dir.Replace("\n", "").Split(System.Convert.ToChar('\r'))) | |
{ | |
//parse | |
if (!string.IsNullOrEmpty( line)) | |
{ | |
this.Add(new FTPfileInfo(line, path)); | |
} | |
} | |
} | |
/// <summary> | |
/// Filter out only files from directory listing | |
/// </summary> | |
/// <param name="ext">optional file extension filter</param> | |
/// <returns>FTPdirectory listing</returns> | |
public FTPdirectory GetFiles(string ext) | |
{ | |
return this.GetFileOrDir(FTPfileInfo.DirectoryEntryTypes.File, ext); | |
} | |
/// <summary> | |
/// Returns a list of only subdirectories | |
/// </summary> | |
/// <returns>FTPDirectory list</returns> | |
/// <remarks></remarks> | |
public FTPdirectory GetDirectories() | |
{ | |
return this.GetFileOrDir(FTPfileInfo.DirectoryEntryTypes.Directory, ""); | |
} | |
//internal: share use function for GetDirectories/Files | |
private FTPdirectory GetFileOrDir(FTPfileInfo.DirectoryEntryTypes type, string ext) | |
{ | |
FTPdirectory result = new FTPdirectory(); | |
foreach (FTPfileInfo fi in this) | |
{ | |
if (fi.FileType == type) | |
{ | |
if (string.IsNullOrEmpty( ext )) | |
{ | |
result.Add(fi); | |
} | |
else if (ext == fi.Extension) | |
{ | |
result.Add(fi); | |
} | |
} | |
} | |
return result; | |
} | |
public bool FileExists(string filename) | |
{ | |
foreach (FTPfileInfo ftpfile in this) | |
{ | |
if (ftpfile.Filename == filename) | |
{ | |
return true; | |
} | |
} | |
return false; | |
} | |
private const char slash = '/'; | |
public static string GetParentDirectory(string dir) | |
{ | |
string tmp = dir.TrimEnd(slash); | |
int i = tmp.LastIndexOf(slash); | |
if (i > 0) | |
{ | |
return tmp.Substring(0, i - 1); | |
} | |
else | |
{ | |
throw (new ApplicationException("No parent for root")); | |
} | |
} | |
} | |
#endregion | |
public string ftpServerIP { get; set; } | |
public string ftpUserID { get; set; } | |
public string ftpPassword { get; set; } | |
public void DownloadFile(string filePath, string fileName, string ftpPassword, string ftpUserID, string ftpServerIP) | |
{ | |
FtpWebRequest reqFTP; | |
try | |
{ | |
//filePath = <<The full path where the file is to be created.>>, | |
//fileName = <<Name of the file to be created(Need not be the name of the file on FTP server).>> | |
FileStream outputStream = new FileStream(filePath + "\\" + fileName, FileMode.Create); | |
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + fileName)); | |
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile; | |
reqFTP.UseBinary = true; | |
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); | |
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); | |
Stream ftpStream = response.GetResponseStream(); | |
int bufferSize = 2048; | |
int readCount; | |
byte[] buffer = new byte[bufferSize]; | |
readCount = ftpStream.Read(buffer, 0, bufferSize); | |
while (readCount > 0) | |
{ | |
outputStream.Write(buffer, 0, readCount); | |
readCount = ftpStream.Read(buffer, 0, bufferSize); | |
} | |
ftpStream.Close(); | |
outputStream.Close(); | |
response.Close(); | |
} | |
catch | |
{ | |
} | |
} | |
} | |
} | |
//public static void voidShutcut() | |
//{ | |
// try | |
// { | |
// IWshRuntimeLibrary.WshShellClass class2 = new IWshRuntimeLibrary.WshShellClass(); | |
// IWshRuntimeLibrary.IWshShortcut shortcut = class2.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\E-Hekim Destek Sistemi.lnk") as IWshRuntimeLibrary.IWshShortcut; | |
// shortcut.TargetPath = Environment.CurrentDirectory + @"\destek.exe"; | |
// shortcut.WindowStyle = 1; | |
// shortcut.Description = "E-Destek"; | |
// shortcut.WorkingDirectory = Environment.CurrentDirectory; | |
// shortcut.IconLocation = Environment.CurrentDirectory + @"\veico.ico"; | |
// shortcut.Save(); | |
// string[] dosya = File.ReadAllLines(Environment.CurrentDirectory + @"\Environment.ini"); | |
// File.Delete(Environment.CurrentDirectory + @"\Environment.ini"); | |
// for (int i = 0; i < dosya.Length; i++) | |
// { | |
// if (i != 1) | |
// { | |
// File.AppendAllText(Environment.CurrentDirectory + @"\Environment.ini", dosya[i].ToString()); | |
// } | |
// else if (i == 1) | |
// { | |
// File.AppendAllText(Environment.CurrentDirectory + @"\Environment.ini", "Shutcut 1"); | |
// } | |
// File.AppendAllText(Environment.CurrentDirectory + @"\Environment.ini", Environment.NewLine); | |
// } | |
// } | |
// catch (Exception ex) | |
// { | |
// voidSetExceptionMessage(ex.Message + Environment.NewLine + ex.StackTrace); | |
// } | |
//} | |
//public static string hataBildir(Exception ex) | |
//{ | |
// string sonuc = "1"; | |
// try | |
// { | |
// sonuc = webservis.ExceptionAl(SINIF.LISANS.GetProgramNo(), ex.Message, ex.Source, ex.StackTrace, ex.TargetSite.Name); | |
// } | |
// catch | |
// { | |
// sonuc = "0"; | |
// } | |
// return sonuc; | |
//} | |
} | |
public static class GELISMIS_SQL | |
{ | |
public static class TABLO | |
{ | |
public static string TabloSil(string TabloAdı) | |
{ | |
string sonuc = ""; | |
sonuc = glb.executeQuery("drop table "+TabloAdı); | |
return sonuc; | |
} | |
public static bool TabloVarmi(string TabloAdı) | |
{ | |
bool sonuc=false; | |
DATABASE.VeriTabaniDegistir("information_schema", false); | |
if (Conn.Database == "information_schema") | |
{ | |
sonuc= glb.checkRecord("TABLE_SCHEMA='"+GecerliSunucu.GecerliVeritabani+"' and TABLE_NAME='"+TabloAdı+"'", "TABLES"); | |
} | |
DATABASE.VeriTabaniDegistir(GecerliSunucu.GecerliVeritabani, false); | |
disposeFromMemory(); | |
return sonuc; | |
} | |
} | |
public static class COLUMN | |
{ | |
} | |
public static class DATABASE | |
{ | |
public static string DbYolu = Environment.CurrentDirectory + @"\settings\db.ini"; | |
public static string VeriTabaniDegistir(string YeniVeritabani, bool KaliciOlarakDegistir) | |
{ | |
string sonuc = ""; | |
if (KaliciOlarakDegistir) | |
{ | |
GecerliSunucu.GecerliVeritabani = YeniVeritabani; | |
} | |
Conn.ChangeDatabase(YeniVeritabani); | |
disposeFromMemory(); | |
return sonuc; | |
} | |
} | |
public static class GecerliSunucu | |
{ | |
public static string GecerliVeritabani | |
{ | |
get | |
{ | |
string[] cstr2 = File.ReadAllLines(Environment.CurrentDirectory + @"\settings\db.ini"); | |
return cstr2[3]; | |
} | |
set | |
{ | |
UTILITY.MetinBelgesindeSatirDegistir(Environment.CurrentDirectory + @"\settings\db.ini", 4, value); | |
} | |
} | |
public static string GecerliServer | |
{ | |
get | |
{ | |
string[] cstr2 = File.ReadAllLines(Environment.CurrentDirectory + @"\settings\db.ini"); | |
return cstr2[0]; | |
} | |
set | |
{ | |
UTILITY.MetinBelgesindeSatirDegistir(Environment.CurrentDirectory + @"\settings\db.ini", 1, value); | |
} | |
} | |
public static string GecerliSifre | |
{ | |
get | |
{ | |
string[] cstr2 = File.ReadAllLines(Environment.CurrentDirectory + @"\settings\db.ini"); | |
return cstr2[2]; | |
} | |
set | |
{ | |
UTILITY.MetinBelgesindeSatirDegistir(Environment.CurrentDirectory + @"\settings\db.ini", 3, value); | |
} | |
} | |
public static string GecerliKullanici | |
{ | |
get | |
{ | |
string[] cstr2 = File.ReadAllLines(Environment.CurrentDirectory + @"\settings\db.ini"); | |
return cstr2[1]; | |
} | |
set | |
{ | |
UTILITY.MetinBelgesindeSatirDegistir(Environment.CurrentDirectory + @"\settings\db.ini", 2, value); | |
} | |
} | |
public static string GecerliPort | |
{ | |
get | |
{ | |
string[] cstr2 = File.ReadAllLines(Environment.CurrentDirectory + @"\settings\db.ini"); | |
return cstr2[4]; | |
} | |
set | |
{ | |
UTILITY.MetinBelgesindeSatirDegistir(Environment.CurrentDirectory + @"\settings\db.ini", 5, value); | |
} | |
} | |
} | |
public static DataTable getDifferentRecords(DataTable FirstDataTable, DataTable SecondDataTable) | |
{ | |
//Create Empty Table | |
DataTable ResultDataTable = new DataTable("ResultDataTable"); | |
//use a Dataset to make use of a DataRelation object | |
using (DataSet ds = new DataSet()) | |
{ | |
//Add tables | |
ds.Tables.AddRange(new DataTable[] { FirstDataTable.Copy(), SecondDataTable.Copy() }); | |
//Get Columns for DataRelation | |
DataColumn[] firstColumns = new DataColumn[ds.Tables[0].Columns.Count]; | |
for (int i = 0; i < firstColumns.Length; i++) | |
{ | |
firstColumns[i] = ds.Tables[0].Columns[i]; | |
} | |
DataColumn[] secondColumns = new DataColumn[ds.Tables[1].Columns.Count]; | |
for (int i = 0; i < secondColumns.Length; i++) | |
{ | |
secondColumns[i] = ds.Tables[1].Columns[i]; | |
} | |
//Create DataRelation | |
DataRelation r1 = new DataRelation(string.Empty, firstColumns, secondColumns, false); | |
ds.Relations.Add(r1); | |
DataRelation r2 = new DataRelation(string.Empty, secondColumns, firstColumns, false); | |
ds.Relations.Add(r2); | |
//Create columns for return table | |
for (int i = 0; i < FirstDataTable.Columns.Count; i++) | |
{ | |
ResultDataTable.Columns.Add(FirstDataTable.Columns[i].ColumnName, FirstDataTable.Columns[i].DataType); | |
} | |
//If FirstDataTable Row not in SecondDataTable, Add to ResultDataTable. | |
ResultDataTable.BeginLoadData(); | |
foreach (DataRow parentrow in ds.Tables[0].Rows) | |
{ | |
DataRow[] childrows = parentrow.GetChildRows(r1); | |
if (childrows == null || childrows.Length == 0) | |
ResultDataTable.LoadDataRow(parentrow.ItemArray, true); | |
} | |
//If SecondDataTable Row not in FirstDataTable, Add to ResultDataTable. | |
foreach (DataRow parentrow in ds.Tables[1].Rows) | |
{ | |
DataRow[] childrows = parentrow.GetChildRows(r2); | |
if (childrows == null || childrows.Length == 0) | |
ResultDataTable.LoadDataRow(parentrow.ItemArray, true); | |
} | |
ResultDataTable.EndLoadData(); | |
} | |
return ResultDataTable; | |
} | |
//public static DataTable GetTableOfSelectedRows(DevExpress.XtraGrid.Views.Grid.GridView view) | |
//{ | |
// DataTable table = new DataTable(); | |
// DataTable table2 = null; | |
// if (view.DataSource is DataView) | |
// { | |
// table2 = ((DataView)view.DataSource).Table; | |
// } | |
// else if (view.DataSource is BindingSource) | |
// { | |
// table2 = ((DataView)((BindingSource)view.DataSource).List).Table; | |
// } | |
// if (table2 != null) | |
// { | |
// table = table2.Clone(); | |
// for (int i = 0; i < view.RowCount; i++) | |
// { | |
// DataRow dataRow = view.GetDataRow(i); | |
// table.Rows.Add(dataRow.ItemArray); | |
// } | |
// table.AcceptChanges(); | |
// } | |
// return table; | |
//} | |
} | |
public static class WinApi | |
{ | |
public const int AW_BLEND = 0x80000; | |
public const int AW_CENTER = 0x10; | |
public const int AW_HIDE = 0x10000; | |
public const int AW_HOR_NEGATIVE = 2; | |
public const int AW_HOR_POSITIVE = 1; | |
public const int AW_SLIDE = 0x40000; | |
public const int AW_VER_NEGATIVE = 8; | |
public const int AW_VER_POSITIVE = 4; | |
[DllImport("user32.dll", CharSet = CharSet.Auto)] | |
public static extern int AnimateWindow(IntPtr hwand, int dwTime, int dwFlags); | |
} | |
public static void Open() | |
{ | |
if (Conn.State != ConnectionState.Open) | |
{ | |
string[] cstr = new string[5]; | |
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=anadosk.mdb;User Id=admin;Password=;"; | |
Conn.Open(); | |
if (komut==null) | |
{ | |
komut = new OleDbCommand(); | |
} | |
komut.Connection = Conn; | |
} | |
} | |
public static void OpenWithoutDb() | |
{ | |
if (Conn.State != ConnectionState.Open) | |
{ | |
string[] cstr = new string[5]; | |
cstr = File.ReadAllLines(Environment.CurrentDirectory + @"\settings\db.ini"); | |
Conn.ConnectionString = "Server=" + cstr[0].ToString() + ";Uid=" + cstr[1].ToString() + ";Password=" + cstr[2].ToString() + ";Port=" + cstr[4]; | |
if (komut == null) | |
{ | |
komut = new OleDbCommand(); | |
} | |
komut.Connection = Conn; | |
Conn.Open(); | |
} | |
} | |
public static bool checkRecord(string WhereStr,string TableName) | |
{ | |
bool flag = false; | |
if (Conn.State == ConnectionState.Closed) | |
{ | |
Conn.Open(); | |
} | |
if (TableName.Trim().Length > 0) | |
{ | |
object c = dataCell("select * from " + TableName + " where " + WhereStr); | |
if (c != null) | |
{ | |
if (c != null || c.GetType().ToString() != "System.DBNull") | |
{ | |
flag = true; | |
} | |
} | |
else | |
{ | |
flag = false; | |
} | |
} | |
disposeFromMemory(); | |
return flag; | |
} | |
public static object dataCell(string SelectCommandText) | |
{ | |
object obj2 = null; | |
try | |
{ | |
if (Conn.State == ConnectionState.Closed) | |
{ | |
Open(); | |
} | |
OleDbCommand command = new OleDbCommand(SelectCommandText, Conn); | |
command.CommandText = SelectCommandText; | |
obj2 = command.ExecuteScalar(); | |
command = null; | |
} | |
catch | |
{ | |
obj2 = null; | |
} | |
disposeFromMemory(); | |
return obj2; | |
} | |
public static DataRow dataRow(string SelectCommandText) | |
{ | |
DataRow row = null; | |
if (Conn.State == ConnectionState.Closed) | |
{ | |
Open(); | |
} | |
DataTable dataTable = new DataTable(); | |
new OleDbDataAdapter(SelectCommandText, Conn).Fill(dataTable); | |
if (dataTable.Rows.Count > 0) | |
{ | |
row = dataTable.Rows[0]; | |
} | |
dataTable = null; | |
disposeFromMemory(); | |
return row; | |
} | |
public static DataTable dataTable(string SelectCommandText, string TableNameUsing) | |
{ | |
DataTable dataTable = new DataTable(); | |
try | |
{ | |
if (Conn.State == ConnectionState.Closed) | |
{ | |
Open(); | |
} | |
new OleDbDataAdapter(SelectCommandText, Conn).Fill(dataTable); | |
if (!string.IsNullOrEmpty( TableNameUsing)) | |
{ | |
dataTable.TableName = TableNameUsing; | |
} | |
} | |
catch(Exception ex) | |
{ | |
string q = ex.Message; | |
} | |
disposeFromMemory(); | |
return dataTable; | |
} | |
public static string executeQuery(string Sql) | |
{ | |
string sonuc = "İşlem başarılı."; | |
try | |
{ | |
if (Conn.State!=ConnectionState.Open) | |
{ | |
glb.Open(); | |
if (Conn.State!=ConnectionState.Open) | |
{ | |
glb.OpenWithoutDb(); | |
} | |
} | |
komut = new OleDbCommand(); | |
komut.Connection = Conn; | |
Sql.Replace("'", @"\'"); | |
komut.CommandText = Sql; | |
komut.ExecuteNonQuery(); | |
komut = null; | |
disposeFromMemory(); | |
} | |
catch (Exception ex) | |
{ | |
sonuc = "İşlem Başarısız.Hata Kodu : " + ex.Message; | |
} | |
return sonuc; | |
} | |
public static void disposeFromMemory() | |
{ | |
try | |
{ | |
GC.WaitForPendingFinalizers(); | |
} | |
catch | |
{ | |
} | |
} | |
public static long executeQueryFoto(string Sql, object resim) | |
{ | |
int num = -1000; | |
if (Conn.State == ConnectionState.Closed) | |
{ | |
Conn.Open(); | |
} | |
OleDbCommand command = new OleDbCommand(); | |
command.Connection = Conn; | |
command.CommandText = Sql; | |
command.Parameters.AddWithValue("@Dosya", resim); | |
try | |
{ | |
num = command.ExecuteNonQuery(); | |
disposeFromMemory(); | |
command.Dispose(); | |
} | |
catch | |
{ | |
} | |
return (long)num; | |
} | |
public static string DegerArtir (string Tablo,string Kolon,string Where) | |
{ | |
return glb.executeQuery("update "+Tablo+" set "+Kolon+"="+Kolon+"+1 where "+Where ); | |
} | |
public static string DegerArtir(string Tablo, string Kolon, string Where, int ArtmaSayisi) | |
{ | |
return glb.executeQuery("update " + Tablo + " set " + Kolon + "=" + Kolon + "+" + ArtmaSayisi + " where " + Where); | |
} | |
public static void voidSetExceptionMessage(Exception message) | |
{ | |
File.AppendAllText(Environment.CurrentDirectory + @"\ErrorLog.ini", Environment.NewLine + Environment.NewLine + Environment.NewLine); | |
File.AppendAllText(Environment.CurrentDirectory + @"\ErrorLog.ini", "-----Hata Oluşma Zamanı-----" + Environment.NewLine + DateTime.Now.ToString() + Environment.NewLine + Environment.NewLine); | |
File.AppendAllText(Environment.CurrentDirectory + @"\ErrorLog.ini", "-----Mesaj------" + Environment.NewLine + message.Message + Environment.NewLine + Environment.NewLine); | |
File.AppendAllText(Environment.CurrentDirectory + @"\ErrorLog.ini", "-----Stack Trace------" + Environment.NewLine + message.StackTrace + Environment.NewLine); | |
File.AppendAllText(Environment.CurrentDirectory + @"\ErrorLog.ini", "-----Target Site------" + Environment.NewLine+message.TargetSite + Environment.NewLine); | |
File.AppendAllText(Environment.CurrentDirectory + @"\ErrorLog.ini", "-----------------------------------------------------------------------------------------------------------------"); | |
} | |
public static string voidKullanici() | |
{ | |
string[] a = new string[1]; | |
a = File.ReadAllLines(Environment.CurrentDirectory + @"\Settings\user.ini"); | |
return a[0]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment