korasoglu Posted November 30, 2015 Share Posted November 30, 2015 Arkadaşlar en son açılan klasörü hatırlamsını nasıl yapabilirim. ve varsayılan klasör nasıl tanımlarım. FolderBrowserDialog dlg = new FolderBrowserDialog(); dlg.Description = @"Klasör Seçiniz"; if (dlg.ShowDialog() == DialogResult.OK) Quote Link to comment Share on other sites More sharing options...
KintaRo Posted December 1, 2015 Share Posted December 1, 2015 string yol = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); // seçilen yolu kaydetmek için global değişken (form kapanana kadar geçerlidir.) private void button1_Click(object sender, EventArgs e) { FolderBrowserDialog dlg = new FolderBrowserDialog(); dlg.SelectedPath = yol; // kaydediler yolu al dlg.Description = @"Klasör Seçiniz"; if (dlg.ShowDialog() == DialogResult.OK) { yol = dlg.SelectedPath; // yolu kaydet // kodlar } } Quote Link to comment Share on other sites More sharing options...
korasoglu Posted December 1, 2015 Author Share Posted December 1, 2015 regedite kayıt edilip çekilse o zaman format atılana kadar hatırlar. mantığı anladım bir araştırıyım. Belki işine yarayan olur. Microsoft.Win32.RegistryKey key; key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("DENEME1"); key.SetValue("EKLE", "BIR"); key.Close(); RegistryKey key2 = Registry.CurrentUser.OpenSubKey(@"DENEME1"); object aa = key2.GetValue("EKLE"); MessageBox.Show(aa.ToString()); key2.Close(); Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted December 2, 2015 Share Posted December 2, 2015 Yalnız registry işlemlerinde kullanıcı admin değilse sorun yaşarsın. Ben herzaman XML ile kullanıcının belgelerim klasörüne yazıyorum bu tarz bilgileri, tavsiye ederim. Quote Link to comment Share on other sites More sharing options...
korasoglu Posted December 2, 2015 Author Share Posted December 2, 2015 (edited) Peki o zaman yönetici olarak nasıl çalıştırırız. Edit: Projenizi kodlarken, menüden Açılan dosyada şu satırı bulun; <requestedExecutionLevel> Şununla değiştirin; <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> Böyle yapılıyormuş. Edited December 2, 2015 by korasoglu Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted December 2, 2015 Share Posted December 2, 2015 tamamda eğer domain controller yapısında bir bilgisayar ise admin olarak açamaz normal kullanıcılar, domain admin yada local admin olması gerekir kullanıcıların... bence registry ile işlem yapma ama tabiki yine de sen bilirsin... Quote Link to comment Share on other sites More sharing options...
KintaRo Posted December 2, 2015 Share Posted December 2, 2015 Bir programcı her ihtimali düşünmelidir, murat'a katılıyorum :) Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted December 2, 2015 Share Posted December 2, 2015 (edited) Bunu kendine göre uyarlarsan sorun çıkmaz ; string Path = ""; string xmlpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Settings.xml"; private void xmlOKU() { try { XmlDocument xml = new XmlDocument(); xml.Load(xmlpath); XmlNodeList Settings = xml.SelectNodes("//Settings"); foreach (XmlNode Setting in Settings) { Path = Setting.SelectSingleNode("Path").InnerText; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void xmlYAZ(newPath) { try { XmlDocument xml = new XmlDocument(); xml.Load(xmlpath); XmlNode nodeToFind; nodeBUL = xml.SelectSingleNode("//Settings"); if (nodeBUL == null) { XmlElement newcatalogentry = xml.CreateElement("Settings"); XmlElement Pathstr = xml.CreateElement("Path"); Pathstr.InnerText = newPath; newcatalogentry.AppendChild(Pathstr); xml.DocumentElement.InsertAfter(newcatalogentry, xml.DocumentElement.LastChild); xml.Save(xmlpath); } else { foreach (XmlElement element in xml.SelectNodes("//Settings")) { element.SelectSingleNode("//Path").InnerText = newPath; xml.Save(xmlpath); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void xmlOLUSTUR() { try { XmlDocument xmlDoc = new XmlDocument(); XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null); XmlElement rootNode = xmlDoc.CreateElement("root"); xmlDoc.InsertBefore(xmlDeclaration, xmlDoc.DocumentElement); xmlDoc.AppendChild(rootNode); xmlDoc.Save(xmlpath); } catch (XmlException ex) { MessageBox.Show(ex.Message); } } private void button1_Click(object sender, EventArgs e) { FolderBrowserDialog dlg = new FolderBrowserDialog(); dlg.SelectedPath = Path; dlg.Description = @"Klasör Seçiniz"; if (dlg.ShowDialog() == DialogResult.OK) { xmlYAZ(dlg.SelectedPath); } } private void Form1_Load(object sender, EventArgs e) { if (File.Exists(xmlpath)) { try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlpath); XmlElement root = xmlDoc.DocumentElement; if (root != null) { xmlOKU(); } else { xmlOLUSTUR(); xmlOKU(); } } catch (XmlException ex) { xmlOLUSTUR(); xmlOKU(); } } else { xmlOLUSTUR(); xmlOKU(); } } Edited December 2, 2015 by muratboy31 Quote Link to comment Share on other sites More sharing options...
korasoglu Posted December 2, 2015 Author Share Posted December 2, 2015 Eyvallah teşekkür ederim evde bir deneyeyim ikinizede katılıyorum çalıştığım yerde bahsettiğin sorun var tam deneme şansım da var. Quote Link to comment Share on other sites More sharing options...
korasoglu Posted December 4, 2015 Author Share Posted December 4, 2015 Nerede hata yapıyorum anlamadım bir çalışıyor bir çalışmıyor. public static string yol = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); void listele() { RegistryKey key2 = Registry.CurrentUser.OpenSubKey(@"Takip"); if (key2 == null) { key2.Close(); Microsoft.Win32.RegistryKey key; key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Takip"); MessageBox.Show(yol); key.SetValue("Klasor", yol.ToString()); key.Close(); } else { object aa = key2.GetValue("Klasor"); yol = aa.ToString(); MessageBox.Show(yol); key2.Close(); } } listele(); FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.SelectedPath = yol; dialog.Description = "Seçim Yapınız"; if (dialog.ShowDialog() == DialogResult.OK) { yol = dialog.SelectedPath; MessageBox.Show(yol); Microsoft.Win32.RegistryKey key6; key6 = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Takip"); key6.SetValue("Klasor", yol); key6.Close(); } Quote Link to comment Share on other sites More sharing options...
MostWanted Posted December 4, 2015 Share Posted December 4, 2015 Bence harici bi xml dosyası ile uğraşmak bu durum için fazla komplike bir iş. Daha önce paylaştığım http://www.tnctr.com/topic/278977-film-ysimlendirici-20-kaynak-kod/ konusundaki programda şöyle ufak bir özellik vardı: Bir settings dosyası oluşturup böyle ufak bilgileri oraya kaydedip yine ordan çekmek. Projeyi indirdiğin zaman da göreceksin, proje dosyasında (Visual Studio'da açtığında) Ayarlar.Settings dosyası var. Çift tıklandığında bir sürü girdi göreceksin, bunlardan biri startup_folder. Tipi string scope'u user falan filan. Sen de kendi projende böyle girdi oluşturup istediğini yapabilirsin. Kod düzeyinde ise şöyle kullanılıyor; yol = Ayarlar.Default.startup_folder; // get işlemi Set içinse şöyle yapabilirsin; Ayarlar.Default.startup_folder = "yeni_yolun_neyse" // set işlemi Ayarlar.save() (Değişkenleri, stringleri falan uygun bir şekilde değiştirebileceğini varsayıyorum.) Quote Link to comment Share on other sites More sharing options...
korasoglu Posted December 5, 2015 Author Share Posted December 5, 2015 İndirdim fakat sln uzantılı bir dosya göremedim. Quote Link to comment Share on other sites More sharing options...
MostWanted Posted December 5, 2015 Share Posted December 5, 2015 Visual Studio'yu açtıktan sonra open project diyip movierenamer.csproj dosyasını açmanız yeterli. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.