繁体   English   中英

如何使用app.config使控制台应用程序传输大于4 MB的文件

[英]How can I make my console application transfer files bigger than 4 MB using app.config

我有幸进一步开发使用C#编写的内部控制台应用程序。 此应用程序的目的是将多个文件从一台服务器同步到另一台服务器,基本上是将文件从一台服务器复制到另一台服务器。 该应用程序适用于最大4 MB的文件,但在应用程序本身的任何地方都找不到它,该文件将日志文件以外的文件大小限制为4 MB。

该控制台应用程序是Web应用程序的一部分,该Web应用程序存储用户创建的表单。 我设法将Web应用程序限制为允许文件大小不超过100 MB,并且可以正常工作,但是同步应用程序不会将较大的文件从软件仓库传输到另一台服务器上的相应位置。

不幸的是,除了记录文件(不超过4 MB)传输的文件的日志,我没有其他日志。 调试该应用程序是不可行的,因为它仅在服务器上运行,并且无法在本地计算机上运行。

因此,我的问题是,是否有可能在app.config文件中设置任何内容以允许应用程序也同步大于4 MB的文件?

在这个大项目的Web应用程序部分中,我使用了以下代码:

<system.web>
    <httpRuntime maxRequestLength="102400" executionTimeout="1200"/>
</system.web>

但是由于这部分不是Web应用程序,因此(似乎)不必关心该配置行。

这是控制台同步应用程序的配置文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>
        <add key="SynchConfiguration" value="C:\Documents and Settings\My Documents\Visual Studio 2010\Projects\DepotSynch\Depot.Synch\DepotSynchConfiguration.xml"/>
        <add key="SynchLog"  value="C:\Documents and Settings\My Documents\Visual Studio 2010\Projects\DepotSynch\Depot.Synch\DepotSynchLOG.txt"/>
        <!-- Int Size in MB -->
        <add key="MaxLogFileSize" value="4"/>

        <!-- SHS Web Service API Configuration -->
        <add key="Status" value="test"/>
        <add key="From" value="1234567890"/>
        <!-- Identification Nummer -->
        <add key="To"  value="1234567890.web"/>
        <add key="CertLocation" value="certificate\test\test.p12"/>
        <!-- placeing of certet i filsystemet -->
        <add key="CertPwd" value="test234test"/>
        <!-- cert -->
        <!-- <add key="ShsUrl" value="Is set ini DepotSynchConfiguration.xml for each environment"/> -->
        <!-- URL to Shs Service -->
        <add key="ConnectByCertAndPwd" value="true"/>
        <!-- True/False - for certificate -->
        <add key="SendFileBySHS" value="false"/>
        <!-- For test. Won't send the file/s. -->
    </appSettings>

    <system.serviceModel>
        <bindings>
          <wsHttpBinding>
            <binding name="MyWsHttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
                </security>
            </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:50232/Depot.svc"  binding="wsHttpBinding" bindingConfiguration="MyWsHttpBinding" contract="DepotReleaseServiceReference.IDepot" name="MyWsHttpBinding">
                <identity>
                    <servicePrincipalName value="&#xD;&#xA;          " />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

不幸的是,自从两年前他辞职以来,我无法去寻求原始开发人员的帮助。

我有一个Web应用程序,这是解决问题的方法,将这行代码放在您的配置文件中

<system.webServer>
  ...
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="2147483647" />
    </requestFiltering>
  </security>
</system.webServer>

[编辑]另外请看一下这个话题

读取XML数据时超出了最大字符串内容长度配额(8192)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM