Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

File Path Error

Posted on 2010-09-01
10
Medium Priority
?
1,431 Views
Last Modified: 2012-05-10
Error Paths

I have an application that saves the excel files to a location on another server.  users will be accessing this application, so I decided to use UNC paths.  However, I am getting an error.

UNC Path:
string strFile = @"\MY SERVER\Inetpub\wwwroot\BALAReporting\Invalid DataInetpub\wwwroot\BALAReporting\Invalid Data\InvalidData_" + postdate + ".xls";

Open in new window


Error exporting data to spreadsheet

System.Runtime.InteropServices.COMException (0x800A03EC): 'C:\hqspsdev01\Inetpub\wwwroot\BALAReporting\Invalid DataInetpub\wwwroot\BALAReporting\Invalid Data\InvalidData_090110_050502PM.xls' cannot be accessed. The file may be corrupted, located on a server that is not responding, or read-only. at Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs(Object Filename, Object FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local) at DelinquentReport.exportToExcel(DataTable dt, String fileloc) in c:\Inetpub\wwwroot\DelinquentRep\Default.aspx.cs:line 291 at DelinquentReport.btnInvalidData_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\DelinquentRep\Default.aspx.cs:line 356


with the path changed to:

string strFile = @"\\MY SERVER\Inetpub\wwwroot\BALAReporting\Invalid DataInetpub\wwwroot\BALAReporting\Invalid Data\InvalidData_" + postdate + ".xls";

Open in new window


I get the following error:

Error exporting data to spreadsheet

System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC at Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs(Object Filename, Object FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local) at DelinquentReport.exportToExcel(DataTable dt, String fileloc) in c:\Inetpub\wwwroot\DelinquentRep\Default.aspx.cs:line 291 at DelinquentReport.btnInvalidData_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\DelinquentRep\Default.aspx.cs:line 356

what can i do to prevent the error?



0
Comment
Question by:ayoZen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 1000 total points
ID: 33581662
has it got something to do with the read access?
e.g. is it open for read only instead of read/write / create?
0
 
LVL 7

Assisted Solution

by:jdavistx
jdavistx earned 1000 total points
ID: 33581711
Is your path copied from your code, or did you type it? It appears to be missing a backslash before "Inetpub"

You also appear to have this in there twice:
"Inetpub\wwwroot\BALAReporting\Invalid Data"
0
 
LVL 7

Expert Comment

by:jdavistx
ID: 33581715
Try this as your string?
string strFile = @"\\MY SERVER\Inetpub\wwwroot\BALAReporting\Invalid Data\InvalidData_" + postdate + ".xls";

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:ayoZen
ID: 33588376
i updated my file and still get the following error:

Error exporting data to spreadsheet to
THIS IS THE PATH
\\MY SERVER NAME HERE\Inetpub\wwwroot\BALAReporting\Invalid Data\InvalidData_090210_120902PM.xls

System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC at Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs(Object Filename, Object FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local) at DelinquentReport.exportToExcel(DataTable dt, String fileloc) in c:\Inetpub\wwwroot\DelinquentRep\Default.aspx.cs:line 291 at DelinquentReport.btnInvalidData_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\DelinquentRep\Default.aspx.cs:line 359
0
 

Author Comment

by:ayoZen
ID: 33588385
I set the avriable to :

[code]
string strFile = @"\\MY SERVER\Inetpub\wwwroot\BALAReporting\Invalid Data\InvalidData_" + postdate + ".xls";
[/code]
0
 

Author Comment

by:ayoZen
ID: 33588694
I tried to modify the folder permissions too?  Is the error indicating that the problem is the path or the folder?
0
 
LVL 7

Expert Comment

by:jdavistx
ID: 33589874
Not sure, are you able to simply write a new file to that folder via Windows explorer? If so, then it's not a persmission issue.
0
 

Author Comment

by:ayoZen
ID: 33591425
yes.  i can save files to that folder without a problem.  
0
 
LVL 7

Expert Comment

by:jdavistx
ID: 33599439
Can you write this file locally?
0
 

Author Comment

by:ayoZen
ID: 33662463
Thank you jdavistx and TheRealLoki for your help!  After careful reveiw, I created a folder on the same server without a problem.  I changed the saveas option in my excelExport method:

[code]
owb.SaveAs(fileloc, Excel.XlFileFormat.xlWorkbookNormal, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode.xlExclusive, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
[/code]

finally,  my file names became:

[code]
           string postdate = Convert.ToString(DateTime.Now.ToString("MMddyy_hhmmsstt"));
           string dirName = @"C:\BALA Delinquent App\Delinquent Reports\";
           string strFile = "delinquentReport_" + postdate + ".xls";
            DirectoryInfo dInfo = new DirectoryInfo(dirName);
....rest of code
 exportToExcel(gt, dInfo + strFile);
[/code]

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question