السلام عليكم
قمت بانشاء web service لرفع الملفات
واستدعيت هذه ال service في windows application
واريد أن أجعل البرنامج يرفع اكثر من ملف في نفس الوقت
اعتقد أنه يمكن تنفيذ هذه الفكرة باستخدام ال multithreading ,ولكن لا أعرف كيف أنفذها
هذه هي الدالة التي قمت باستخدامها لاستدعاء ال web service
private void UploadFile(string filename)
{
try
{
String strFile = System.IO.Path.GetFileName(filename);
// create an instance fo the web service
TestUploader.ServiceSoapClient srv = new FileUploader.TestUploader.ServiceSoapClient();
// get the file information form the selected file
FileInfo fInfo = new FileInfo(filename);
// get the length of the file to see if it is possibleto upload it (with the standard 4 MB limit)
long numBytes = fInfo.Length;
double dLen = Convert.ToDouble(fInfo.Length / 1000000);
// Default limit of 15 MB on web server
// have to change the web.config to if
// you want to allow larger uploads
if (dLen < 15)
{
// set up a file stream and binary reader for the
// selected file
FileStream fStream = new FileStream(filename,
FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fStream);
// convert the file to a byte array
byte[] data = br.ReadBytes((int)numBytes);
br.Close();
// pass the byte array (file) and file name to the web service
string sTmp = srv.UploadFile(data, strFile);
fStream.Close();
fStream.Dispose();
// this will always say OK unless an error occurs,
// if an error occurs, the service returns the error message
MessageBox.Show("File Upload Status: " + sTmp, "File Upload");
}
else
{
// Display message if the file was too large to upload
MessageBox.Show("The file selected exceeds the size limit for uploads.", "File Size");
}
}
catch (Exception ex)
{
// display an error message to the user
MessageBox.Show(ex.Message.ToString(), "Upload Error");
}
}فكيف يمكنني رفع أكثر من ملف في ظغطة زر واحد ؟
أرجو الافادة
وجزاكم الله خيرا