Problem opening workbooks

Hello!

I don't know, if it is a Aspose.Cells or an IIS problem (perhaps I'm the problem ;-)). But anyway. Hope to get a solution. Here is my problem:

I have an typical IIS installation under c:\inetpub\wwwroot ... If I open a workbook located on c: (it doesn't matter if it is stored directly on c: or an underlying path of wwwroot, etc.), it works fine.

But know, I have to open a workbook from a network share linked to the webserver. I tried to solve it by passing the whole path like "Z:\Test\Test.xls". I also thought about the virtual path feature from IIS, but I could not imagine how it should work in this situation. Everytime I get the exception that file could not be found. Opening workbooks from local drive d: also doesn't work.

Any suggestions???

When I get this run, then I think, that the workbook.save thing will also work !?!

Michael

Hi,

Well, the issue seems to be of security permission settings or privileges for the IO operation and does not concern with Aspose.Cells for .NET component, I think you are not allowed to access/manipulate the file system completely. To confirm this exception, you may try to open/save the file using File Streams without involving Aspose.Cells for .NET API.

I think you might require proper security settings for your requirements for the drives other than C drive(that works fine currently). You may try to assign Administrative role for your application.

Thank you.

Hi Amjad!

I set the share permissions and the security permission of this path to 1) network service and 2) everyone with full access rights. Both variations do not work. I get (still) the exception "DirectoryNotFoundException" ???

Hi,

I still have a doubt about your web configuration or privileges. What happens when you try to open/save the file using .NET File Streams without using Aspose.Cells for .NET API? Could you try the following sample code to check if it works fine

FileStream fs = File.OpenRead(@“D:\MyFolder\MyBook.xls”);
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
Response.Clear();
Response.ClearHeaders();
Response.ContentType = “application/vnd.ms-excel”;
Response.AddHeader(“Content-Length”, data.Length.ToString());
Response.AddHeader(“content-disposition”, “attachment; filename=Book1.xls”);
Response.BinaryWrite(data);
Response.End();


Thank you.

Hi!

Sorry, that I answer this late, but your post arrived me at weekend time, because of the time difference between us - I think.

I tested your code. The result is:

a) opening from local drive d: --> it worked with full rights for everyone or "only" for network service

b) opening from network share with full rights for everyone and/or network service ends with the exception: DirectoryNotFoundException - A part of the path ... could not be found.

Before and since we talk, I tested this in VS Debug Mode in conjunction with the IIS-Webserver. Today I will test it, after I publish the webapp to the production server. But the network share is the same. So I don't think, that the result will be positive.

I don't know, which more Share- and/or NTFS-permission I should set. You speak of configuration settings for the web.config??

Hi!

I have the solution!!! For you and everyone other who will have the same problem:

The security thing my webapp was missing is impersonation. See the KB from M$: http://support.microsoft.com/kb/306158 .

Also I changed the path to the file to UNC-style.

In the end, my code looks like this:

if (impersonateValidUser("user", "domain", "password"))
{
//Insert your code that runs under the security context of a specific user here.

Workbook wb = new Workbook();
wb.Open(@"\\192.168.1.1\Path\To\File\File.xlt");

Worksheet ws = wb.Worksheets["Table1"];
Cells c = ws.Cells;

c[4, 1].PutValue("Test");

wb.Save(@"\\192.168.1.1\Path\To\File\File.xls");

undoImpersonation();
}