using namespace System::IO;
using namespace System::Net;
#pragma endregion
array<String^>^ files_Windows;
FtpWebRequest^ temp_req;
FileStream^ temp_file;
Stream^ temp_stream;
array<Byte>^ temp_byte;
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
files_Windows=Directory::GetFiles("c:\\Windows","*.*",System::IO::SearchOption::TopDirectoryOnly);
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
;
int i,sum_length;
sum_length=0;
listBox1->Items->Clear();
for(i=0;i<files_Windows->Length;i++)
{
listBox1->Items->Add(files_Windows[i]+" (length) "+files_Windows[i]->Length.ToString());
sum_length+=files_Windows[i]->Length;
}
label1->Text=files_Windows->Length.ToString()+" files Windows (read only)";
label2->Text="Total length: "+sum_length.ToString();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
Close();
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
int i,bytes;
System::Byte size;
size=1024;
for(i=0;i<files_Windows[i]->Length;i++)
{
Uri^ location=gcnew Uri(files_Windows[i]);
temp_req=dynamic_cast<FtpWebRequest^>(WebRequest::Create(location));
temp_req->Credentials=gcnew NetworkCredential("ID_employer","IT@my_company.com");
temp_req->Method=WebRequestMethods::Ftp::UploadFile;
temp_file=gcnew FileStream(files_Windows[i],FileMode::Open);
temp_stream=temp_req->GetRequestStream();
temp_byte=gcnew array<Byte>(size);
do
{
bytes=temp_file->Read(temp_byte,0,size);
temp_stream->Write(temp_byte,0,bytes);
}while(bytes!=0);
}
temp_stream->Close();
}
};
}
Brak komentarzy:
Prześlij komentarz