将文本显示为“文件路径”而不是System [] String [英] Display text as "File Path" instead of System[] String

查看:64
本文介绍了将文本显示为“文件路径”而不是System [] String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有以下代码。我想显示我通过folderBrowser控件选择的文件路径,但它显示System [] String,我该如何解决?



Hi I have the following codes. I wanna display the file path i selected through folderBrowser control but instead it display System[]String, how can i fix it?

private void firstGroupBtn_Click(object sender, EventArgs e)
{
    DialogResult result = folderBrowserDialog1.ShowDialog();
    if (result == DialogResult.OK)
    {
        string[] files = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
        foreach (var value in files)
        {
            firstGroupTxt.Text = value;
        }
    }
}

推荐答案

不,您的代码没有按照您的描述进行操作。它会显示文件数量。如果你报告一些问题,你应该提供确切的代码,你在检测到问题时使用的代码,而不是其他任何东西。



计算<$ c的目的$ c>文件不清楚;你从来没有提过它。路径是 folderBrowserDialog1.SelectedPath 。如果你想展示,展示它,而不是其他任何东西。



-SA
No, your code is not doing what you described. It would display number of files. If you report some problem, you should provide exact code, the code you used when you detected the problem, not anything else.

The purpose of calculation of files is not clear; you never mentioned it. The path is folderBrowserDialog1.SelectedPath. If you want to show it, show it, not anything else.

—SA


使用以下代码显示所选路径



Use the following codes to display the path selected

private void firstGroupBtn_Click(object sender, EventArgs e)
{
    DialogResult result = folderBrowserDialog1.ShowDialog();

    if (result == DialogResult.OK)
    {
        firstGroupTxt.Text = folderBrowserDialog1.SelectedPath;
    }
}


这篇关于将文本显示为“文件路径”而不是System [] String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆