Solved

File Path Error

Posted on 2010-09-01
10
1,407 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

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…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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