I need includes:
using namespace System::IO;
using namespace System::Net;
And code:
#pragma endregion
array<String^>^ files_Windows;
String^ address_ftp;
Uri^ send_address;
array<Byte>^ table;
String^ path;
int size;
Stream^ f_stream;
FtpWebRequest ^send_FTP;
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
int i;
address_ftp="ftp.company.com";
table=gcnew array<Byte>(2048);
path="info.txt";
files_Windows=Directory::GetFiles("c:\\Windows","*.*",System::IO::SearchOption::TopDirectoryOnly);
size=files_Windows->Length;
for(i=0;i<size;i++)
listBox1->Items->Add("( "+files_Windows[i]+" )");
;
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
StreamWriter^ my_Stream=gcnew StreamWriter(path);
int i,length_bytes;
for(i=0;i<size;i++)
my_Stream->WriteLine(files_Windows[i]);
send_address=gcnew Uri("ftp://"+address_ftp);
send_FTP=dynamic_cast<FtpWebRequest^>(WebRequest::Create(send_address));
send_FTP->Credentials=gcnew NetworkCredential("employee_name","employee@company.com");
send_FTP->Method+WebRequestMethods::Ftp::UploadFile;
FileStream^ use_file=gcnew FileStream(path,FileMode::Open);
f_stream=send_FTP->GetRequestStream();
do
{
length_bytes=use_file->Read(table,0,2048);
f_stream->Write(table,0,length_bytes);
}while(length_bytes!=0);
f_stream->Close();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
Close();
}
};
}
Brak komentarzy:
Prześlij komentarz