![]() |
C# Metinden dosya ve klasör adı üretme
C# Metinden dosya ve klasör adı üretme
Metindeki özel karakterleri çıkararak güvenli şekilde dosya ve klasör adı üreten fonksiyon (Metinden dosya adı üretme = metinden-dosya-adi-uretme) Kod: public static string FilenameFromTitle(string name) { string safe = name.Trim(); safe = safe.Replace(" ", "-").ToLower(); if(safe.IndexOf("--") > -1) while(safe.IndexOf("--") > -1) safe = safe.Replace("--", "-"); safe = Regex.Replace(safe, "[^a-z0-9\\-]", ""); if(safe.Length > 50) safe = safe.Substring(0, 49); // clean the beginning and end of the filename char[] replace = {'-','.'}; safe = safe.TrimStart(replace); safe = safe.TrimEnd(replace); return safe; } |
| Forum saati; Türkiye'ye göre ayarlanmış olup, şu an saat: 05:53. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Navbar with Avatar by Motorradforum