Solved

File Path Error

Posted on 2010-09-01
10
1,391 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
  • 5
  • 4
10 Comments
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 250 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 250 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Entity Framework 7 43
Exit the loop 4 45
Video Player 2017 5 26
Jquery/JSON passing value from one function to another 12 41
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

825 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