12,162
社区成员
发帖
与我相关
我的任务
分享
public string SaveFile(string sn, string qty,string file1,string file2,string file3,string file4,string file5)
{
StringBuilder sb = new StringBuilder();
sb.Length = 0;
sb.Append(file1);
sb.Append(file2);
sb.Append(file3);
sb.Append(file4);
sb.Append(file5);
string srcPath = sb.ToString();
if (sn==null || sn=="")
{
return "sn is null";
}
if (srcPath==null)
{
return "srcPath is null";
}
try
{
#region 方案1
DateTime time = DateTime.Now;
string tim = time.ToString("yyyyMMddHHmmss");
string str = srcPath; //convert string 2 stream
byte[] array = new byte[str.Length / 2];
int j = 0;
for (int i = 0; i < str.Length; i += 2)
{
string s = str.Substring(i, 2); //取16进制2位
int n = Convert.ToInt16(s, 16); //将2位16进制,转10进制
array[j] = (byte)Int32.Parse(n.ToString()); //最后结果给字节数组
j++;
}
//创建将要写入的目标位置,
FileStream fg = new FileStream(@"E:\File\" + tim + "_" + sn + "_" + qty + ".tgz", FileMode.Create);
fg.Write(array, 0, array.Length); //将字节数组一次写入,目标位置
fg.Close();
}
catch (Exception ex)
{
return "false!info:"+ ex;
}
return "trueno" + srcPath;
}
<?xml version="1.0" encoding="utf-8"?>
<!--
有关如何配置 ASP.NET 应用程序的详细信息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<identity impersonate="false" />
<authentication mode="Forms" />
<compilation targetFramework="4.5" />
<httpRuntime maxRequestLength = "102400000" executionTimeout="3600" />
<webServices>
<protocols>
<add name="HttpSoap"/>
<add name="HttpPost"/>
<add name="HttpGet"/>
<add name="Documentation"/>
</protocols>
</webServices>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>