当我将文件夹保存在某个位置时,它会存储在上面的文件夹中

发布于 2024-07-16 22:48:43 字数 838 浏览 5 评论 0原文

我导入一个文件,对其进行处理并将其保存在某个位置。 我将文件保存在文件夹中,但它保存在所选文件夹上方的文件夹中。 这是代码,

    private void btnSave_Click(object sender, EventArgs e)
    {
        FolderBrowserDialog saveFile = new FolderBrowserDialog();
        saveFile.ShowNewFolderButton = true;
        if (saveFile.ShowDialog(this) == DialogResult.OK)

        {
            btnStartImport.Enabled = true;
            txtSaveBookName.Text = saveFile.SelectedPath;
            string r = Path.GetFileNameWithoutExtension(m_ImportFile);
            m_SaveDir = (txtSaveBookName.Text + r);

        }
    }

m_ImportFile给出了我们获取输入文件的文件路径,我希望我保存的文件是我想要将其保存在其中的m_ImportFile.extension的名称。但是通过这种方法我得到我选择的文件夹。我想要的 m_ImportFile.extension 的名称。 例如。 我导入一个文件 chh.xml,所以当我想保存它时,我想获取 chh.xuk,但如果我选择文件夹 ab,则保存文件的路径(如果是 ab.chh.xuk),​​并且也位于所选文件夹上方的文件夹中文件夹。 请帮忙。

I import a file, process it and save it in some location. I am saving my file in a folder but it is getting saved in a folder above the folder selected. Here is the code,

    private void btnSave_Click(object sender, EventArgs e)
    {
        FolderBrowserDialog saveFile = new FolderBrowserDialog();
        saveFile.ShowNewFolderButton = true;
        if (saveFile.ShowDialog(this) == DialogResult.OK)

        {
            btnStartImport.Enabled = true;
            txtSaveBookName.Text = saveFile.SelectedPath;
            string r = Path.GetFileNameWithoutExtension(m_ImportFile);
            m_SaveDir = (txtSaveBookName.Text + r);

        }
    }

m_ImportFile gives the path of the file from where we get the input file, i want my saved file to be of the name of the m_ImportFile.extension that i want to save it in. but by this method i am getting the folder that i select.name of the m_ImportFile.extension i want. Eg. I import a file chh.xml, so when i want to save it i want to get chh.xuk but if i select a folder ab then the path of saved file if ab.chh.xuk and that too in a folder above the selected folder. Please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅气尐潴 2024-07-23 22:48:43

尝试:

m_SaveDir = Path.Combine(txtSaveBookName.Text, r);

Try:

m_SaveDir = Path.Combine(txtSaveBookName.Text, r);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文