Hello ))
Guys tell me please - in which folder should I put the file ( a few folders in one project), so that the program will be able to "read" it. if the path = "something.txt".
Thanks in advance ))

string startupPath1 = System.IO.Directory.GetCurrentDirectory();
//or:
string startupPath2 = Application.StartupPath;

This will return the path of the debug diredctory in the current project.

if you want to read the file from the debuf folder in your current project you simply bind the text file, like:

string startupPath2 = Application.StartupPath + @"\something.txt"; //or maybe without backslash! try it(I am doing this code by my heart).

I am doing this code by my heart

good phrase)) I'll try ) but why need @ ??

If you dont use the sign "@" on the beginning of the path`s string, you have to write double back slashes for seperating folder. Example:

string path1 = @"C:\myFoler\myFile.txt";
string path2 = "C:\\myFolder\\myFile.txt";

I hope you see the difference between these two examples.

Mitja

I hope you see the difference between these two examples.

undeniably! Thank you))

You could always create a directory specifically for your application which would house many important files pertinent to the aforementioned application.

public string storageDirectory;

public void InstallStorageDirectory()
{
    // I've found that LocalApplicationData and ApplicationData seem to be interchangeable.
    this.storageDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\yourStorageDir"

    if (!IO.Directory.Exists(this.storageDirectory))
    {
        try
        {
            Directory.CreateDirectory(path);
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }
    else
    {
        Console.WriteLine("..the storage directory is already installed");
    }
}
commented: +++++ +1
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.