Copy File


#pragma once

namespace My12 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::IO;
///
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
///

public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
///
/// Clean up any resources being used.
///

~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ BtnCopyFile;
private: System::Windows::Forms::Label^ lblSource;
private: System::Windows::Forms::Label^ lblDes;
protected:
protected:
private:
///
/// Required designer variable.
///

System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

void InitializeComponent(void)
{
this->BtnCopyFile = (gcnew System::Windows::Forms::Button());
this->lblSource = (gcnew System::Windows::Forms::Label());
this->lblDes = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// BtnCopyFile
//
this->BtnCopyFile->Location = System::Drawing::Point(12, 118);
this->BtnCopyFile->Name = L"BtnCopyFile";
this->BtnCopyFile->Size = System::Drawing::Size(524, 33);
this->BtnCopyFile->TabIndex = 0;
this->BtnCopyFile->Text = L"Copy File";
this->BtnCopyFile->UseVisualStyleBackColor = true;
this->BtnCopyFile->Click += gcnew System::EventHandler(this, &Form1::BtnCopyFile_Click);
//
// lblSource
//
this->lblSource->AutoSize = true;
this->lblSource->Location = System::Drawing::Point(14, 21);
this->lblSource->Name = L"lblSource";
this->lblSource->Size = System::Drawing::Size(66, 13);
this->lblSource->TabIndex = 1;
this->lblSource->Text = L"Source File :";
//
// lblDes
//
this->lblDes->AutoSize = true;
this->lblDes->Location = System::Drawing::Point(14, 75);
this->lblDes->Name = L"lblDes";
this->lblDes->Size = System::Drawing::Size(85, 13);
this->lblDes->TabIndex = 2;
this->lblDes->Text = L"Destination File :";
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(548, 163);
this->Controls->Add(this->lblDes);
this->Controls->Add(this->lblSource);
this->Controls->Add(this->BtnCopyFile);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
//Copy File
String^Source_File;
String^Destination_File;
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
Source_File= "C:\\01.Bmp";
Destination_File ="D:\\01.Bmp";
lblSource->Text="Source File : "+Source_File;
lblDes->Text="Destination File : "+Destination_File;
}
private: System::Void BtnCopyFile_Click(System::Object^ sender, System::EventArgs^ e) {
File::Copy(Source_File,Destination_File);
MessageBox::Show("Copy Completed","Copy File",System::Windows::Forms::MessageBoxButtons::OK,
System::Windows::Forms::MessageBoxIcon::Information);
}
};
}