V
V
Vladimir Yurchenkov2019-02-17 07:20:04
C++ / C#
Vladimir Yurchenkov, 2019-02-17 07:20:04

Why doesn't file.exists see the file?

private void button2_Click(object sender, EventArgs e) // Кнопка проверки
        {
            if (textBox1.Text == string.Empty) // Условие если поле пустое
            {
                MessageBox.Show("Вы не указали сетевое имя!");
                return;
            }
            Directory.Exists(@"G:\std\profiles\" + textBox1.Text);
            if (File.Exists("cfg.txt"))
            {
                rezu.Text = ("Профиль существует!");
                rezu.ForeColor = Color.Red;
                return;
            }
            else
                rezu.Text = ("Профиль пустой!");
            rezu.ForeColor = Color.Green;

        }

Help me understand why File.Exits writes that the file is not in the specified category, in fact it is there.
There are suspicions that it is not correctly written here, I am a beginner.
Directory.Exists(@"G:\std\profiles\" + textBox1.Text);
            if (File.Exists("cfg.txt"))

p.s. folder permissions are not required

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2019-02-17
@EPIDEMIASH

Specify the full path in the call to File.Exists()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question