using System;
usingSystem.Collections.Generic;

usingSystem.Text;
using System.IO;

namespace ConsoleApplication1
{
class Program
    {
stringchoice,c,d,E;

public void n()
        {
Console.WriteLine("Welcome To Turning GNIITians Discovery !!!!");
Console.WriteLine("");
Console.WriteLine("Choice-");
Console.WriteLine("A.New");

Console.WriteLine("B.Edit");
Console.WriteLine("C.Close");
Console.WriteLine("");
Console.WriteLine("         Enter Your Choice From The Above:-             ");
choice = Console.ReadLine();
Directory.CreateDirectory("D:\\SMBRD");
if (choice == "A")
            {
Console.WriteLine("Enter Your File Name(Max 8 characters)-");


                    string name = Console.ReadLine();

                    if(name.Length>8 || name.Length<=0)
                    {
                        do
                        {
                            Console.WriteLine("Please re-enter file name");
                            name = Console.ReadLine();
                        }
                        while(name.Length>8 || name.Length<=0);
                    }


                    else
                    {
                        Console.WriteLine("         Enter Your Data         ");
                        E = Console.ReadLine();
                        FileStreamfs = new FileStream(@"D:\SMBRD\" + name + ".txt", FileMode.Create, FileAccess.Write, FileShare.Write);
                        StreamWriterst = new StreamWriter(fs);
                        st.WriteLine(E);
                        st.Flush();
                        st.Close();
                        fs.Close();
                    }

            }

else if (choice == "B")
            {
string search;
Console.WriteLine("Please Enter The FileName");
search= Console.ReadLine();
StreamReadersr = new StreamReader(new FileStream(@"D:\SMBRD\" + search + ".txt", FileMode.Open, FileAccess.ReadWrite));
sr.BaseStream.Seek(0, SeekOrigin.Begin);

stringnem = sr.ReadToEnd();

if (nem != null)
                {

Console.WriteLine("");
Console.WriteLine(nem);
Console.WriteLine("");
Console.WriteLine("Want to Edit??");

if (c == "y")
                    {
Console.WriteLine("Enter The Data");
                        d = Console.ReadLine();
FileStreamfs = new FileStream(@"D:\SMBRD\" + search + ".txt", FileMode.Append, FileAccess.Write);
StreamWriterstt = new StreamWriter(fs);
stt.WriteLine(d);
Console.WriteLine("Data Saved");

                    }



                }

            }

else if (choice == "c")
            {
Console.WriteLine("Thank You For Using HC Notepad !!!!");
Environment.Exit(0);

            }
        }





static void Main(string[] args)
        {
            Program m = new Program();
m.n();
Console.ReadLine();
        }
    }
}

It is successfully Running .. But there Are Some Problems ....

  1. I Want to Know How To search files that are saved on the Driive ??
  2. ANy more suggestions regarding it?
  3. How to Make It more UseFul ?

Please also me the mistakes i am doing in it.

Recommended Answers

All 3 Replies

I Want to Know How To search files that are saved on the Driive ??

For starters, check this Daniweb thread to search for files.

I will suggest you to go for winform instead of console application.

I agree with Codefiva, but if you insist on using a console app, perhaps have a look at this codesnippet. Also avoid us names as n for your methods use a meaningfull name.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.