Solved

File Path Error

Posted on 2010-09-01
10
1,400 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 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
Technology Partners: 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!

 

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
What are the simplest ways to create a Merge Sort? 3 37
Coding for the first time 9 69
Set custom font WPF 2 21
Using sample Autorize.net c# simple example 1 26
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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