| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 534 人关注过本帖
标题:求助: C++如何判断目录中,是否存在某一类文件
只看楼主 加入收藏
追梦人zmrghy
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:406
专家分:190
注 册:2021-4-9
结帖率:97.26%
收藏
 问题点数:0 回复次数:0 
求助: C++如何判断目录中,是否存在某一类文件
C++如何判断目录中,是否存在某一类文件
图片附件: 游客没有浏览图片的权限,请 登录注册


图片附件: 游客没有浏览图片的权限,请 登录注册




转换前判断是否有指定(.ts .avi .wmv .3gp .flv .qsv)格式的视频文件存在。。。。。


程序代码:
#pragma once

namespace ToMP4Converter {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;

    /// <summary>
    /// Form1 摘要
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            //TODO:  在此处添加构造函数代码
            //
        }

    protected:
        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::GroupBox^ groupBox1;
    protected:
    private: System::Windows::Forms::RadioButton^ radioButton6;
    private: System::Windows::Forms::RadioButton^ radioButton5;
    private: System::Windows::Forms::RadioButton^ radioButton4;
    private: System::Windows::Forms::RadioButton^ radioButton3;
    private: System::Windows::Forms::RadioButton^ radioButton2;
    private: System::Windows::Forms::RadioButton^ radioButton1;
    private: System::Windows::Forms::Label^ label1;
    private: System::Windows::Forms::Label^ label2;
    private: System::Windows::Forms::TextBox^ textBox1;
    private: System::Windows::Forms::TextBox^ textBox2;
    private: System::Windows::Forms::Button^ button1;
    private: System::Windows::Forms::Button^ button2;
    private: System::Windows::Forms::CheckBox^ checkBox1;
    private: System::Windows::Forms::Button^ button3;
    private: System::Windows::Forms::FolderBrowserDialog^ folderBrowserDialog1;

    private:
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
        /// <summary>
        /// 设计器支持所需的方法 - 不要修改
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        void InitializeComponent(void)
        {
            this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
            this->radioButton6 = (gcnew System::Windows::Forms::RadioButton());
            this->radioButton5 = (gcnew System::Windows::Forms::RadioButton());
            this->radioButton4 = (gcnew System::Windows::Forms::RadioButton());
            this->radioButton3 = (gcnew System::Windows::Forms::RadioButton());
            this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());
            this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->button2 = (gcnew System::Windows::Forms::Button());
            this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
            this->button3 = (gcnew System::Windows::Forms::Button());
            this->folderBrowserDialog1 = (gcnew System::Windows::Forms::FolderBrowserDialog());
            this->groupBox1->SuspendLayout();
            this->SuspendLayout();
            // 
            // groupBox1
            // 
            this->groupBox1->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(128)), static_cast<System::Int32>(static_cast<System::Byte>(255)),
                static_cast<System::Int32>(static_cast<System::Byte>(128)));
            this->groupBox1->Controls->Add(this->radioButton6);
            this->groupBox1->Controls->Add(this->radioButton5);
            this->groupBox1->Controls->Add(this->radioButton4);
            this->groupBox1->Controls->Add(this->radioButton3);
            this->groupBox1->Controls->Add(this->radioButton2);
            this->groupBox1->Controls->Add(this->radioButton1);
            this->groupBox1->Dock = System::Windows::Forms::DockStyle::Top;
            this->groupBox1->Font = (gcnew System::Drawing::Font(L"宋体", 12));
            this->groupBox1->Location = System::Drawing::Point(0, 0);
            this->groupBox1->Name = L"groupBox1";
            this->groupBox1->Size = System::Drawing::Size(684, 53);
            this->groupBox1->TabIndex = 0;
            this->groupBox1->TabStop = false;
            this->groupBox1->Text = L"输入视频格式";
            // 
            // radioButton6
            // 
            this->radioButton6->AutoSize = true;
            this->radioButton6->Font = (gcnew System::Drawing::Font(L"宋体", 10));
            this->radioButton6->Location = System::Drawing::Point(481, 24);
            this->radioButton6->Name = L"radioButton6";
            this->radioButton6->Size = System::Drawing::Size(53, 18);
            this->radioButton6->TabIndex = 5;
            this->radioButton6->TabStop = true;
            this->radioButton6->Text = L".qsv";
            this->radioButton6->UseVisualStyleBackColor = true;
            this->radioButton6->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton6_CheckedChanged);
            // 
            // radioButton5
            // 
            this->radioButton5->AutoSize = true;
            this->radioButton5->Font = (gcnew System::Drawing::Font(L"宋体", 10));
            this->radioButton5->Location = System::Drawing::Point(393, 24);
            this->radioButton5->Name = L"radioButton5";
            this->radioButton5->Size = System::Drawing::Size(53, 18);
            this->radioButton5->TabIndex = 4;
            this->radioButton5->TabStop = true;
            this->radioButton5->Text = L".flv";
            this->radioButton5->UseVisualStyleBackColor = true;
            this->radioButton5->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton6_CheckedChanged);
            // 
            // radioButton4
            // 
            this->radioButton4->AutoSize = true;
            this->radioButton4->Font = (gcnew System::Drawing::Font(L"宋体", 10));
            this->radioButton4->Location = System::Drawing::Point(305, 24);
            this->radioButton4->Name = L"radioButton4";
            this->radioButton4->Size = System::Drawing::Size(53, 18);
            this->radioButton4->TabIndex = 3;
            this->radioButton4->TabStop = true;
            this->radioButton4->Text = L".3gp";
            this->radioButton4->UseVisualStyleBackColor = true;
            this->radioButton4->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton6_CheckedChanged);
            // 
            // radioButton3
            // 
            this->radioButton3->AutoSize = true;
            this->radioButton3->Font = (gcnew System::Drawing::Font(L"宋体", 10));
            this->radioButton3->Location = System::Drawing::Point(217, 24);
            this->radioButton3->Name = L"radioButton3";
            this->radioButton3->Size = System::Drawing::Size(53, 18);
            this->radioButton3->TabIndex = 2;
            this->radioButton3->TabStop = true;
            this->radioButton3->Text = L".wmv";
            this->radioButton3->UseVisualStyleBackColor = true;
            this->radioButton3->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton6_CheckedChanged);
            // 
            // radioButton2
            // 
            this->radioButton2->AutoSize = true;
            this->radioButton2->Font = (gcnew System::Drawing::Font(L"宋体", 10));
            this->radioButton2->Location = System::Drawing::Point(129, 24);
            this->radioButton2->Name = L"radioButton2";
            this->radioButton2->Size = System::Drawing::Size(53, 18);
            this->radioButton2->TabIndex = 1;
            this->radioButton2->TabStop = true;
            this->radioButton2->Text = L".avi";
            this->radioButton2->UseVisualStyleBackColor = true;
            this->radioButton2->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton6_CheckedChanged);
            // 
            // radioButton1
            // 
            this->radioButton1->AutoSize = true;
            this->radioButton1->Font = (gcnew System::Drawing::Font(L"宋体", 10));
            this->radioButton1->Location = System::Drawing::Point(48, 24);
            this->radioButton1->Name = L"radioButton1";
            this->radioButton1->Size = System::Drawing::Size(46, 18);
            this->radioButton1->TabIndex = 0;
            this->radioButton1->TabStop = true;
            this->radioButton1->Text = L".ts";
            this->radioButton1->UseVisualStyleBackColor = true;
            this->radioButton1->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton6_CheckedChanged);
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Font = (gcnew System::Drawing::Font(L"宋体", 10));
            this->label1->Location = System::Drawing::Point(0, 85);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(105, 14);
            this->label1->TabIndex = 1;
            this->label1->Text = L"视频输入路径:";
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Font = (gcnew System::Drawing::Font(L"宋体", 10));
            this->label2->Location = System::Drawing::Point(0, 132);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(105, 14);
            this->label2->TabIndex = 2;
            this->label2->Text = L"MP4 保存路径:";
            // 
            // textBox1
            // 
            this->textBox1->Font = (gcnew System::Drawing::Font(L"宋体", 12));
            this->textBox1->Location = System::Drawing::Point(98, 80);
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(502, 26);
            this->textBox1->TabIndex = 3;
            // 
            // textBox2
            // 
            this->textBox2->Font = (gcnew System::Drawing::Font(L"宋体", 12));
            this->textBox2->Location = System::Drawing::Point(98, 126);
            this->textBox2->Name = L"textBox2";
            this->textBox2->Size = System::Drawing::Size(502, 26);
            this->textBox2->TabIndex = 4;
            // 
            // button1
            // 
            this->button1->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(192)),
                static_cast<System::Int32>(static_cast<System::Byte>(192)));
            this->button1->Font = (gcnew System::Drawing::Font(L"宋体", 10));
            this->button1->Location = System::Drawing::Point(606, 80);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(68, 26);
            this->button1->TabIndex = 5;
            this->button1->Text = L"浏  览";
            this->button1->UseVisualStyleBackColor = false;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // button2
            // 
            this->button2->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(192)),
                static_cast<System::Int32>(static_cast<System::Byte>(192)));
            this->button2->Font = (gcnew System::Drawing::Font(L"宋体", 10));
            this->button2->Location = System::Drawing::Point(607, 126);
            this->button2->Name = L"button2";
            this->button2->Size = System::Drawing::Size(68, 26);
            this->button2->TabIndex = 6;
            this->button2->Text = L"浏  览";
            this->button2->UseVisualStyleBackColor = false;
            this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
            // 
            // checkBox1
            // 
            this->checkBox1->AutoSize = true;
            this->checkBox1->Checked = true;
            this->checkBox1->CheckState = System::Windows::Forms::CheckState::Checked;
            this->checkBox1->Font = (gcnew System::Drawing::Font(L"宋体", 10));
            this->checkBox1->Location = System::Drawing::Point(3, 168);
            this->checkBox1->Name = L"checkBox1";
            this->checkBox1->Size = System::Drawing::Size(124, 18);
            this->checkBox1->TabIndex = 7;
            this->checkBox1->Text = L"删除原视频文件";
            this->checkBox1->UseVisualStyleBackColor = true;
            // 
            // button3
            // 
            this->button3->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(192)),
                static_cast<System::Int32>(static_cast<System::Byte>(192)));
            this->button3->Font = (gcnew System::Drawing::Font(L"宋体", 12));
            this->button3->Location = System::Drawing::Point(280, 198);
            this->button3->Name = L"button3";
            this->button3->Size = System::Drawing::Size(113, 34);
            this->button3->TabIndex = 8;
            this->button3->Text = L"开始转换";
            this->button3->UseVisualStyleBackColor = false;
            this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(192)), static_cast<System::Int32>(static_cast<System::Byte>(255)),
                static_cast<System::Int32>(static_cast<System::Byte>(255)));
            this->ClientSize = System::Drawing::Size(684, 245);
            this->Controls->Add(this->button3);
            this->Controls->Add(this->checkBox1);
            this->Controls->Add(this->button2);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->label1);
            this->Controls->Add(this->groupBox1);
            this->MaximumSize = System::Drawing::Size(700, 284);
            this->MinimumSize = System::Drawing::Size(700, 284);
            this->Name = L"Form1";
            this->Text = L"ToMP4Converter";
            this->groupBox1->ResumeLayout(false);
            this->groupBox1->PerformLayout();
            this->ResumeLayout(false);
            this->PerformLayout();

        }
#pragma endregion
    private: String^ InPath;                //视频输入路径
    private: String^ OutPath;                //MP4 保存路径
    private: static String^ InType = ".ts"; //输入视频文件格式

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
    {
        if (folderBrowserDialog1->ShowDialog() == Windows::Forms::DialogResult::OK)
        {
            textBox1->Text = folderBrowserDialog1->SelectedPath;
        }
    }
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
    if (folderBrowserDialog1->ShowDialog() == Windows::Forms::DialogResult::OK)
    {
        textBox2->Text = folderBrowserDialog1->SelectedPath;
    }
}
private: System::Void radioButton6_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
{
    InType = ((RadioButton^)sender)->Text;
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) 
{

}
};
}



转换前判断是否有指定(.ts .avi .wmv .3gp .flv .qsv)格式的视频文件存在。。。。。

开始转换 是 button3
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)
{
    如何判断,目录是否存在 选定类型的视频文件 (.ts .avi .wmv .3gp .flv .qsv)
}
搜索更多相关主题的帖子: System Size Forms Windows private 
2022-12-03 22:58
快速回复:求助: C++如何判断目录中,是否存在某一类文件
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.060137 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved