输入字符串的格式不正确怎么解决啊 求大神

jacksonrui1 2016-09-16 10:26:56
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------

输入字符串的格式不正确。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.FormatException: 输入字符串的格式不正确。

源错误:


行 83: {
行 84: importer.PrepareDataFiles(new object[] { selectedValue });
行 85: ProductHelper.ImportProducts((DataTable) importer.ParseProductData(new object[] { path })[0], categoryId, brandId, delete, true);
行 86: if (this.chkDeleteFiles.Checked)
行 87: {

堆栈跟踪:


[FormatException: 输入字符串的格式不正确。]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7472247
System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) +146
Hishop.Transfers.TaobaoImporters.Yfx1_2_from_Taobao5_0.ParseProductData(Object[] importParams) +3058
Hidistro.UI.Web.Admin.product.ImportFromTB.btnImport_Click(Object sender, EventArgs e) in g:\仿京东大型商城\Hidistro.UI.Web\App_Code\Admin\product\ImportFromTB.cs:85
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565



代码如下:
private void btnImport_Click(object sender, EventArgs e)
{
if (this.CheckItems())
{
string selectedValue = this.dropFiles.SelectedValue;
string path = Path.Combine(this._dataPath, Path.GetFileNameWithoutExtension(selectedValue));
ImportAdapter importer = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue, new object[0]);---这一行报错

int categoryId = this.dropCategories.SelectedValue.Value;
int? brandId = this.dropBrandList.SelectedValue;
ProductSaleStatus delete = ProductSaleStatus.Delete;
if (this.radInStock.Checked)
{
delete = ProductSaleStatus.OnStock;
}
if (this.radUnSales.Checked)
{
delete = ProductSaleStatus.UnSale;
}
if (this.radOnSales.Checked)
{
delete = ProductSaleStatus.OnSale;
}
selectedValue = Path.Combine(this._dataPath, selectedValue);
if (!File.Exists(selectedValue))
{
this.ShowMsg("选择的数据包文件有问题!", false);
}
else
{
importer.PrepareDataFiles(new object[] { selectedValue });
ProductHelper.ImportProducts((DataTable) importer.ParseProductData(new object[] { path })[0], categoryId, brandId, delete, true);
if (this.chkDeleteFiles.Checked)
{
File.Delete(selectedValue);
Directory.Delete(path, true);
}
this.BindFiles();
this.ShowMsg("此次商品批量导入操作已成功!", true);
}
}
}
...全文
8385 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
天远3132 2018-06-30
  • 打赏
  • 举报
回复
就这质量还核心……你们运维得多费心啊
wdqu 2017-11-02
  • 打赏
  • 举报
回复
引用 4 楼 jacksonrui1 的回复:
已用邮箱让管理员删除这个帖子!!!怎么还没有删除呢!本帖子不小心涉及了核心商业信息!!!再次请求版主删除!!!万分感谢!!!
这还商业核心信息,一百度一堆
jacksonrui1 2016-10-01
  • 打赏
  • 举报
回复
已用邮箱让管理员删除这个帖子!!!怎么还没有删除呢!本帖子不小心涉及了核心商业信息!!!再次请求版主删除!!!万分感谢!!!
jacksonrui1 2016-09-17
  • 打赏
  • 举报
回复
本人菜鸟。。。可以说详细些不 别人的程序我在调试 把这个字符串加个不为空判断语句 int ii = 0;//0代表默认值 String Test = importer.ToString();//判空避免报错 加在那一行报错的上方吗?? private void btnImport_Click(object sender, EventArgs e) { if (this.CheckItems()) { string selectedValue = this.dropFiles.SelectedValue; string path = Path.Combine(this._dataPath, Path.GetFileNameWithoutExtension(selectedValue)); ImportAdapter importer = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue, new object[0]); int categoryId = this.dropCategories.SelectedValue.Value; int? brandId = this.dropBrandList.SelectedValue; ProductSaleStatus delete = ProductSaleStatus.Delete; if (this.radInStock.Checked) { delete = ProductSaleStatus.OnStock; } if (this.radUnSales.Checked) { delete = ProductSaleStatus.UnSale; } if (this.radOnSales.Checked) { delete = ProductSaleStatus.OnSale; } selectedValue = Path.Combine(this._dataPath, selectedValue); if (!File.Exists(selectedValue)) { this.ShowMsg("选择的数据包文件有问题!", false); } else { int ii = 0;//0代表默认值 String Test = importer.ToString();//判空避免报错 if (!int.TryParse(Test, out ii)) return;//把这个字符串加个不为空判断语句 importer.PrepareDataFiles(new object[] { selectedValue }); ProductHelper.ImportProducts((DataTable) importer.ParseProductData(new object[] { path })[0], categoryId, brandId, delete, true);----这一行报错 if (this.chkDeleteFiles.Checked) { File.Delete(selectedValue); Directory.Delete(path, true); } this.BindFiles(); this.ShowMsg("此次商品批量导入操作已成功!", true); } } } 之前么
threenewbee 2016-09-16
  • 打赏
  • 举报
回复
代码中有将字符串或者什么东西转换成数字,但是这个字符串不能转换成数字或者有空格,自己调试下,
江南小鱼 2016-09-16
  • 打赏
  • 举报
回复
单边调试下GetImporter方法,打断点进去呗

62,272

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧