У меня есть следующий метод, чтобы загружать archivosa кривизну Веба service, но у меня есть проблема. Как я могу увеличивать максимальный размер груза?, здесь в метод он это помещает: Возможно оставлять отверстие для любого размера?
private void UploadFile(string filename)
{
try
{
// get the exact file name from the path
String strFile = System.IO.Path.GetFileName(filename);
// create an instance fo the web service
TestUploader.Uploader.FileUploader srv = new
TestUploader.Uploader.FileUploader();
// get the file information form the selected file
FileInfo fInfo = new FileInfo(filename);
long numBytes = fInfo.Length;
double dLen = Convert.ToDouble(fInfo.Length / 1000000);
if (dLen < 4)
{
// 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");
}
}
Возможно конфигурировать tamaГ±o mГЎximo груза файла посредством следующих линий, так как из-за default он 4mb.
web.config
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="xxxx" executionTimeout="1600" requestLengthDiskThreshold="xxxx" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="xxxx" />
</requestFiltering>
</security>
</system.webServer>
Помнить, что количество размещается в битах:
для mГЎs informaciГіn видеть httpRuntime
Я Верю в то, что, если твой тест uploadFile - следующий:
у тебя должен быть web.config, так как ты делаешь инстанцию Услуги
https://www.c-sharpcorner.com/article/upload-any-type-of-file-through-a-C-Sharp-web-service /