如何允许用户写他想在C#中保存所选文件的位置 [英] how to allow the user to write where he want to save the selected files in c#

查看:129
本文介绍了如何允许用户写他想在C#中保存所选文件的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rivate string GetFilename(string file)
        {
            int length = file.Length - (file.LastIndexOf("\\") + 1) - 4;
            return file.Substring(file.LastIndexOf("\\") + 1, length);

        }

        private string GetExtension(string file)
        {
            return file.Substring(file.LastIndexOf(".") + 1);

        }

        private void MsbuildGeneratorBtn_Click(object sender, EventArgs e)
        {
            GenerateMSBuildFile();

            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                this.textBox1.Text = folderBrowserDialog1.SelectedPath;
            }



            
        }

        private void GenerateMSBuildFile()
        {
            List<ProjectFile> projectList = new List<ProjectFile>();
            


            //WriteBuildFileHeader();

            // Add all of the selected files to the template.
            foreach (var projectFile in projectFileList)
            {
                if (projectFile.IsSelected == true)
                {
                    Console.WriteLine(projectFile);
                    projectList.Add(projectFile);
                    //WriteItem(projectFile.FullPath, "C:\\");


                }

            }

推荐答案

其目的不是很清楚,并且未标记要使用的UI库,因此简短的答案是:通过使用其中一个文件对话框.

—SA
The purpose of it is not quite clear, and UI library to be used is not tagged, so the short answer is: by using one of the file dialogs.

—SA


这篇关于如何允许用户写他想在C#中保存所选文件的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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