nopcommerce A disk error occurred during a write operation. (Exception from HRESULT: 0x8003001D (STG_E_WRITEFAULT))

1

i am working in nopcommerce solution 3.90, while importing products, from excel file i get this exception. my code is as follow

public virtual void ImportProductsFromXlsx(Stream stream)
    {
        try
        {
            #region Import business Logic
            using (var xlPackage = new ExcelPackage(stream))
            {
                //get the first worksheet in the workbook
                var worksheet = xlPackage.Workbook.Worksheets.FirstOrDefault();

                if (worksheet == null)
                    throw new NopException("No worksheet found");

                //the columns
                var properties = GetPropertiesByExcelCells<Product>
 (worksheet);

                var manager = new PropertyManager<Product>
 (properties);

                var attributProperties = new[]
.....
.....
 }
}

StackTrace:-

at OfficeOpenXml.Utils.CompoundDocument.ILockBytes.WriteAt(Int64 ulOffset, IntPtr pv, Int32 cb, UIntPtr& pcbWritten) at OfficeOpenXml.Utils.CompoundDocument.GetLockbyte(MemoryStream stream) at OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password) at OfficeOpenXml.ExcelPackage.Load(Stream input) at OfficeOpenXml.ExcelPackage..ctor(Stream newStream) at Nop.Services.ExportImport.ImportManager.ImportProductsFromXlsx(Stream stream) in d:\Arsh\nop3.90\Libraries\Nop.Services\ExportImport\ImportManager.cs:line 330

Solutions That i have tried are :-

  1. Resaving the file to be uploaded using .xlsx extension.
  2. Using Memorystream object.
  3. Adding name of file like(Worksheets.Add("Worksheet Name");)
  4. Removing header text(i.e. header columns like Name, description, etc)

P.S. I am using Nopcommerce. This is inbuilt code of importing products.

c#
asp.net-mvc
excel
nopcommerce-3.90

1 Answer

1

Please try with excel 2010+ because earlier versions of excel differ in encrypt/decrypt algorithm.

You can read more about encryption/decryption here.

answered on Stack Overflow Dec 13, 2017 by Ammar

User contributions licensed under CC BY-SA 3.0