lamont Posted October 20, 2014 Share Posted October 20, 2014 private void button1_Click(object sender, EventArgs e) { bool ds; ds = File.Exists("c:/a.txt"); if (ds == true) MessageBox.Show("Dosya Mevcut"); else if (ds == false) MessageBox.Show("Dosya Mevcut Değil"); } } } arakdaşlar butona tıkladıgım zaman dosya mevcut degil diyor c klasöründe a.txt oluşturuyorum yine aynı şeyi diyor hata nedir ? Quote Link to comment Share on other sites More sharing options...
KintaRo Posted October 20, 2014 Share Posted October 20, 2014 ds = File.Exists(@"c:\a.txt"); veya ds = File.Exists("c:\\a.txt"); şeklinde kullanmalısınız Quote Link to comment Share on other sites More sharing options...
lamont Posted October 20, 2014 Author Share Posted October 20, 2014 (edited) kintaro işe yaramıyor ? Edited October 20, 2014 by lamont Quote Link to comment Share on other sites More sharing options...
abdullahTR Posted October 20, 2014 Share Posted October 20, 2014 (edited) şçyle bişeyde var vs2013 vs hangisini kullanıyosan tam yetki vermen lazım derlerken admin olarak calısacak ve vs2013 yönetici olarak calıstır yoksa calısmaz ben yasadım cünki bu sorunu benim kullandıgım ve calısan yöntem formun loadında kullandıgım if (Directory.Exists(@"C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat")) { button1.Enabled = true; } else { button1.Enabled = false; } butona tıklayıp dosya kopyalamak için ise try { string kaynak = Application.StartupPath + "\\32-bit\\amtlib.dll"; string hedefdosyaismi = Environment.ExpandEnvironmentVariables("%programfiles% (x86)") + @"\Adobe\Acrobat 10.0\Acrobat\amtlib.dll"; string hedefklasor = Environment.ExpandEnvironmentVariables("%programfiles% (x86)") + @"\Adobe\Acrobat 10.0\Acrobat"; if (Directory.Exists(hedefklasor)) { if (File.Exists(kaynak)) { File.Copy(kaynak, hedefdosyaismi, true); MessageBox.Show("Kopyalama Başarılı"); } else { MessageBox.Show("Kopyalanamadı"); } } } catch (Exception) { MessageBox.Show("Klasör Yok !!!!"); } Edited October 20, 2014 by abdullahTR Quote Link to comment Share on other sites More sharing options...
qwerty1986 Posted October 20, 2014 Share Posted October 20, 2014 (edited) windows vista, windows 7....8.1 de C klasörünün altına dosya oluşturma için yönetici yetkisi gerekir a ) exe ni yönetici olarak çalıştır b ) UAC ı devre dışı bırak Edited October 20, 2014 by qwerty1986 Quote Link to comment Share on other sites More sharing options...
lamont Posted October 20, 2014 Author Share Posted October 20, 2014 kardeş c# derliyorum nasıl yönetici oalrak çalıştıracam ama c: kalsöründe a.txt diye bir metin belegesi varmı yokmu denemesi yapacak Quote Link to comment Share on other sites More sharing options...
KintaRo Posted October 20, 2014 Share Posted October 20, 2014 windows vista, windows 7....8.1 de C klasörünün altına dosya oluşturma için yönetici yetkisi gerekir a ) exe ni yönetici olarak çalıştır b ) UAC ı devre dışı bırak dosya oluşturmak için evet ama arkadaş sadece dosya kontrolü yapıyor, bunun için admin yetkisi gerekmez. lamont şu şekilde denedim çalışıyor: (win 8.0 x64 kullanıyorum) if (System.IO.File.Exists("C:\\a.txt")) { MessageBox.Show("dosya var"); } else { MessageBox.Show("dosya yok"); } Ayrıca programa admin yetkisi vermek için app.manifest dosyasındaki requestedExecutionLevel satırındaki level requireAdministrator olmalı. yani şuna benzemeli: <security> <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> </requestedPrivileges> </security> ama şu an yaptığın işlem için buna gerek yok Quote Link to comment Share on other sites More sharing options...
lamont Posted October 20, 2014 Author Share Posted October 20, 2014 kintaro aşagıdaki kısım tam olarak nerede ? Ayrıca programa admin yetkisi vermek için app.manifest dosyasındaki requestedExecutionLevel satırındaki level requireAdministrator olmalı. yani şuna benzemeli: Quote Link to comment Share on other sites More sharing options...
KintaRo Posted October 20, 2014 Share Posted October 20, 2014 app.manifest dosyasını olustuman gerek: Quote Link to comment Share on other sites More sharing options...
lamont Posted October 20, 2014 Author Share Posted October 20, 2014 egitim video su izliyorum video çalışıyor aynısını ben yapınca çalışmıyor private void button1_Click(object sender, EventArgs e) { bool ds; ds = File.Exists("c:/a.txt"); if (ds == true) MessageBox.Show("Dosya Mevcut"); else if (ds == false) MessageBox.Show("Dosya Mevcut Değil"); } } } Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 21, 2014 Editor Share Posted October 21, 2014 Dosya yolunu düzgün yazarmısın. C:\\ şeklinde url adresi yazmıyorsun sağa yatık olmayacak slash bi dene çalışmaması için bi engrl yok yani kod doğru Quote Link to comment Share on other sites More sharing options...
KintaRo Posted October 21, 2014 Share Posted October 21, 2014 yukarıda o kadar yazdık hala // yapıyor :facepalm: Quote Link to comment Share on other sites More sharing options...
lamont Posted October 21, 2014 Author Share Posted October 21, 2014 pairs kod egitim video sundada bu şekilde yazılmış o yüznden merak ediyom çünkü video da çalışıyor bu kod bu şekilde ? Quote Link to comment Share on other sites More sharing options...
artal73 Posted October 21, 2014 Share Posted October 21, 2014 C#'ın söz diziminde belirttiğiniz gibi bir ifade yok. Kintaro'nun 2. mesajda belirttiği 2 ifadeden birini kullanın. Quote Link to comment Share on other sites More sharing options...
lamont Posted October 21, 2014 Author Share Posted October 21, 2014 (edited) Caps atayım sorun nedir acaba ? arkadaşlar egitim videolarında çalışıyor kod o yüzndne kafam akrışıyor ? Edited October 21, 2014 by lamont Quote Link to comment Share on other sites More sharing options...
KintaRo Posted October 21, 2014 Share Posted October 21, 2014 team viewer bilgilerini pm ile gönderirsen bakalım. çok merak ettim gerçekten neden olmuyor. Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 21, 2014 Editor Share Posted October 21, 2014 if (File.Exists("C:\\dosya.txt")) MessageBox.Show("Var"); else MessageBox.Show("Yok"); Çalışıyor test ettim. \\ bu işaretleri yanlış girme dikkat et. Quote Link to comment Share on other sites More sharing options...
lamont Posted October 21, 2014 Author Share Posted October 21, 2014 her türlüsünü dendim \\ // \ / hepsini denedim çalışmıyor anlayamdım if (File.Exists("C:\\dosya.txt")) MessageBox.Show("Var"); else MessageBox.Show("Yok"); Çalışıyor test ettim. \\ bu işaretleri yanlış girme dikkat et. Pairs bende şimdi dendim yok diyor dosya olmasına rağmen Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 21, 2014 Editor Share Posted October 21, 2014 dosya.txt yi değiştirdinizmi sizin dosya adıyla. Quote Link to comment Share on other sites More sharing options...
Cyph3r Posted October 21, 2014 Share Posted October 21, 2014 Gerçekten çalışmıyor :D https://vid.me/e/DBW Quote Link to comment Share on other sites More sharing options...
lamont Posted October 21, 2014 Author Share Posted October 21, 2014 (edited) pairs kardeşime tşk ederim sorun oluşturdugum dosyaya uzantı verdigim için çalışmıyormuş oluşturdugumuz dosyaya uzantı degil sadece isim yazılmalıymış uzantıyı kod yazarken verilmemliymiş sorun çözüldü :) Edited October 21, 2014 by lamont Quote Link to comment Share on other sites More sharing options...
Cyph3r Posted October 21, 2014 Share Posted October 21, 2014 @lamont kodların son halini ekleyebilir misin? Ben anlayamadım şu uzantı işini.... :huh: Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 21, 2014 Editor Share Posted October 21, 2014 arkadaş a.txt şeklinde oluşturacağına a.txt.txt diye oluşturmuş dosyayı sorun o yani :D Quote Link to comment Share on other sites More sharing options...
lamont Posted October 21, 2014 Author Share Posted October 21, 2014 cpyh3r kardeş metin belgesi oluşturdum c sürücüsünde isim olarak a.txt olarak isim verdim .txt ekledigim için kod çalışmıyormuş :D 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.