C# Programındaki Hata Nedir?

Cengizhanjj

Femtopat
Katılım
8 Aralık 2022
Mesajlar
52
Daha fazla  
Cinsiyet
Erkek
Selam 2-3 saattir üzerinde uğraştığım koddan hata alıyorum. Kod:

 
C#:
Using System;
Using System. IO;

Namespace sifreuygulamasi.
{
Class program.
{
Static Void main(string[] args)
{ while(true)
{
Console.Write("İşleminizi Girin \n Kayıt için 1 yazin \n giriş için 2 yazin ");
string islem=Console.ReadLine();
if(islem=="2")
{
Console.Write("\nAdinizi Girin: ");
string isim2 = Console.ReadLine();
Console.Write("Sifrenizi Girin: ");
string sifre2 = Console.ReadLine();
String isim = "";
String sifre = "1";
if (isim == isim2 && sifre == sifre2)
{
Console.WriteLine("Giriş Başarılı Hoşgeldin {0}", isim);
}
else.
{
Console.Write("Birisi Yanlış ama hangisi söylemem");
}
}
if(islem=="1");
{

FileStream fs = new FileStream("D://storage/emulated/0/Download deneme.txt",FileMode.Append,FileAccess.Write,FileShare.Write);
StreamWriter sw = new StreamWriter(fs);
Console.Write("Adınız : ");
sw.WriteLine(Console.ReadLine());
sw.Close();
Console.WriteLine("Kayıt Eklendi.");
Console.ReadKey();
}
}

}
}
}

Kodu bu şekilde atarsanız ve hatayı da atarsanız iyi olur.
 
C#:
using System;
using System.IO;

namespace sifreuygulamasi
{
class Program
{
static void Main(string[] args)
{
while (true)
{
Console.Write("İşleminizi Girin \n Kayıt için 1 yazin \n giriş için 2 yazin ");
string islem = Console.ReadLine();

            if (islem == "2")
            {
                Console.Write("\nAdinizi Girin: ");
                string isim2 = Console.ReadLine();
                Console.Write("Sifrenizi Girin: ");
                string sifre2 = Console.ReadLine();

                String isim = "";
                String sifre = "1";

                if (isim == isim2 && sifre == sifre2)
                {
                    Console.WriteLine("Giriş Başarılı Hoşgeldin {0}", isim);
                }
                else
                {
                    Console.Write("Birisi Yanlış ama hangisi söylemem");
                }
            }

            if (islem == "1")
            {
                FileStream fs = new FileStream("D://storage/emulated/0/Download deneme.txt", FileMode.Append, FileAccess.Write, FileShare.Write);
                StreamWriter sw = new StreamWriter(fs);
                Console.Write("Adınız : ");
                sw.WriteLine(Console.ReadLine());
                sw.Close();
                Console.WriteLine("Kayıt Eklendi.");
                Console.ReadKey();
            }
        }
    }
}
}
 
Yine hata alıyorum hata kayıt yerinde kayıt olunmuyor.
 
Tabiki

 
Android dosya erişimine vs izin vermiyor olabilir. Kodu bilgisayarda yazarsanız hata vermeyecektir tahminimce.
 
Bu siteyi kullanmak için çerezler gereklidir. Siteyi kullanmaya devam etmek için çerezleri kabul etmelisiniz. Daha Fazlasını Öğren.…