You must Sign In to post a response.
  • Category: .NET

    Get the in side debug folder details

    Hi Friends,

    I need to find the folder path bin\debug\data\sample.txt .


    This Data folder creating dynamically how to do can you please help me on this


    -Srinivas K
  • #762843
    Hello Srinivas,

    As per my Understanding this is you are asking about in Windows Forms Application.

    You can see like
    MessageBox.Show(Application.StartupPath + "\Data\Sample.txt");

    This will show you : Drive and Application path from where the application is running + bin\Debug\Data\Sample.txt


    Hope this will help you.
    Let me know if you still having doubt.

    If you have doubt than elaborate it in detail so that we can help you better in easy way.


    Keep one thing in your mind. If you want perfect and faster result than describe your query properly.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #762848
    Actually it is C# console application

    In my solution folder having folder structure follows :

    .. bin\debug\Data\test.txt

    i want this path any predefined methods available ?

    Could you please share me sample code ?


    -Srinvias

  • #762849
    Hello Srinivas,

    Refer the below code :

    using System.IO;
    using System.Diagnostics;

    static void Main(string[] args)
    {
    string path = AppDomain.CurrentDomain.BaseDirectory + @"\Data\Sample.txt";
    string ans = null, openpath = null;

    if (!File.Exists(path))
    {
    Console.WriteLine("Path doesn't exists.");
    Console.WriteLine("\nDo you want to create it? Press Y = Yes or N = No");
    Console.WriteLine("Your answer is : ");
    ans = Console.ReadLine();
    if (ans == "Y" || ans == "y")
    {
    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Data");
    File.Create(AppDomain.CurrentDomain.BaseDirectory + @"\Data\Sample.txt");
    Console.WriteLine("\nDirectory created successfully.");

    Console.WriteLine("\nDo you want to open the path? Press Y = Yes or N = No");
    Console.WriteLine("Your answer is : ");
    openpath = Console.ReadLine();
    if (openpath == "Y" || openpath == "y")
    {
    Process.Start(AppDomain.CurrentDomain.BaseDirectory + @"\Data");
    }
    }
    }
    else
    {
    Console.WriteLine("Path does exists.");
    }
    Console.Write("\nPress any key to exit.");
    Console.ReadLine();
    }

    See the attached image. It's an output of this code.


    Hope this is what you are looking for.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

    Delete Attachment


Sign In to post your comments