Verzeichnisse Volumen übergreifend verschieben?
-
Guten Tag. Ich versuche momentan ein Programm zu schreiben was meiner Mutter vereinfacht Musik von ihrem Computer auf ihren MP3-Player zu verschieben.
#pragma once namespace MP3PlayerBackuper { using namespace std; 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; using namespace System::Collections; /// <summary> /// Zusammenfassung für Form1 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: Konstruktorcode hier hinzufügen. // } protected: /// <summary> /// Verwendete Ressourcen bereinigen. /// </summary> ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::TextBox^ textBox1; protected: private: System::Windows::Forms::Button^ button1; private: System::Windows::Forms::Button^ button2; private: System::Windows::Forms::TextBox^ textBox2; private: System::Windows::Forms::TextBox^ textBox3; private: System::Windows::Forms::Button^ button3; private: System::Windows::Forms::Button^ button4; private: System::Windows::Forms::TextBox^ textBox4; private: System::Windows::Forms::TextBox^ textBox5; private: /// <summary> /// Erforderliche Designervariable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Erforderliche Methode für die Designerunterstützung. /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. /// </summary> void InitializeComponent(void) { System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->button1 = (gcnew System::Windows::Forms::Button()); this->button2 = (gcnew System::Windows::Forms::Button()); this->textBox2 = (gcnew System::Windows::Forms::TextBox()); this->textBox3 = (gcnew System::Windows::Forms::TextBox()); this->button3 = (gcnew System::Windows::Forms::Button()); this->button4 = (gcnew System::Windows::Forms::Button()); this->textBox4 = (gcnew System::Windows::Forms::TextBox()); this->textBox5 = (gcnew System::Windows::Forms::TextBox()); this->SuspendLayout(); // // textBox1 // this->textBox1->Location = System::Drawing::Point(12, 12); this->textBox1->Multiline = true; this->textBox1->Name = L"textBox1"; this->textBox1->ReadOnly = true; this->textBox1->Size = System::Drawing::Size(749, 496); this->textBox1->TabIndex = 0; this->textBox1->Text = resources->GetString(L"textBox1.Text"); // // button1 // this->button1->Location = System::Drawing::Point(767, 12); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(165, 240); this->button1->TabIndex = 1; this->button1->Text = L"Backup"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click); // // button2 // this->button2->Location = System::Drawing::Point(766, 265); this->button2->Name = L"button2"; this->button2->Size = System::Drawing::Size(165, 240); this->button2->TabIndex = 3; this->button2->Text = L"Synchronisation"; this->button2->UseVisualStyleBackColor = true; this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click); // // textBox2 // this->textBox2->Location = System::Drawing::Point(12, 514); this->textBox2->Name = L"textBox2"; this->textBox2->Size = System::Drawing::Size(748, 20); this->textBox2->TabIndex = 5; this->textBox2->Text = L"Pfad zum MP3-Player (z.B. F:\\)"; // // textBox3 // this->textBox3->Location = System::Drawing::Point(12, 540); this->textBox3->Name = L"textBox3"; this->textBox3->Size = System::Drawing::Size(748, 20); this->textBox3->TabIndex = 6; this->textBox3->Text = L"Pfad wo das Backup gespeichert werden soll (z.B. C:\\Users\\Ihr Name\\Music\\MP3-Play" L"er Backup)"; // // button3 // this->button3->Location = System::Drawing::Point(766, 511); this->button3->Name = L"button3"; this->button3->Size = System::Drawing::Size(166, 23); this->button3->TabIndex = 7; this->button3->Text = L"Pfad speichern"; this->button3->UseVisualStyleBackColor = true; this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click); // // button4 // this->button4->Location = System::Drawing::Point(766, 537); this->button4->Name = L"button4"; this->button4->Size = System::Drawing::Size(166, 23); this->button4->TabIndex = 8; this->button4->Text = L"Pfad speichern"; this->button4->UseVisualStyleBackColor = true; this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click); // // textBox4 // this->textBox4->Location = System::Drawing::Point(12, -14); this->textBox4->Multiline = true; this->textBox4->Name = L"textBox4"; this->textBox4->Size = System::Drawing::Size(749, 20); this->textBox4->TabIndex = 9; this->textBox4->Visible = false; // // textBox5 // this->textBox5->Location = System::Drawing::Point(12, -14); this->textBox5->Name = L"textBox5"; this->textBox5->Size = System::Drawing::Size(747, 20); this->textBox5->TabIndex = 10; this->textBox5->Visible = false; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(944, 572); this->Controls->Add(this->textBox5); this->Controls->Add(this->textBox4); this->Controls->Add(this->button4); this->Controls->Add(this->button3); this->Controls->Add(this->textBox3); this->Controls->Add(this->textBox2); this->Controls->Add(this->button2); this->Controls->Add(this->button1); this->Controls->Add(this->textBox1); this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle; this->MaximizeBox = false; this->Name = L"Form1"; this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen; this->Text = L"MP3-Player Backuper"; this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) { String^ Laufwerksname = this->textBox2->Text; this->textBox4->Text = Laufwerksname; } private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { String^ Backupordner = this->textBox3->Text; this->textBox5->Text = Backupordner; } private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { String^ Laufwerksname = this->textBox4->Text; String^ Backupordner = this->textBox5->Text; Directory::CreateDirectory(Backupordner); Directory::Move(Laufwerksname, Backupordner); Directory::Delete(Laufwerksname); this->textBox1->Text = "Der Backupvorgang ist nun beendet. Sie können nun mit der Wiederherstellung fortfahren oder dass Programm beenden."; } private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { String^ Laufwerksname = this->textBox4->Text; String^ Backupordner = this->textBox5->Text; Directory::Move(Laufwerksname, Backupordner); Directory::Move(Backupordner, Laufwerksname); this->textBox1->Text = "Die Wiederherstellung wurde abgeschlossen. Sie können das Programm nun beenden."; } }; }
Erstellen kann ich das Programm ohne Fehlermeldungen. Wenn ich dann aber das Programm starte, die Pfade gespeichert habe und das Backup starten möchte gibt mir das Programm einen Fehler aus von wegen es wurde versucht volum übergreifend zuverschieben. Jedoch ist dass ja eigentlich klar bei diesem Programm dass es volume übergreifend verschieben soll^^ Von daher schätze ich dass ich falsche befehle benutzt habe. Kann mir vllt jemannd einen Tipp geben welche Befehle ich lieber benutzen sollte?
-
Das geht nur mit Kopieren (und anschließendem Löschen der Originaldateien), s.a. How to: Copy Directories
P.S. Kennst du schon Windows Forms und Visual C++ MACHT KEINEN SINN!?
Darum gibt es auch nur ein Beispiel für C# und nicht für C++/CLI...