Hello,
I have faced same Issue when uploading excel file into SharePoint list:
Problem:
Before resolving this issue,I was directly browsing the excel file from local system.When i click on upload button, I keep on getting Error "The Microsoft Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data "
I was reading excel file using file upload control as shown below:
if (!uploadfile.HasFile)
{
ltrlMsg.Text = "Please select a valid Excel File";
return;
}
try
{
//reading file from file upload control.
string fileName = uploadfile.PostedFile.FileName;
//Some code goes here
}
catch (Exception Ex1)
{
ltrlMsg.Text = Ex1.Message;
}
For Reference:
Solution:
Then am storing excel file in root directory then reading file path from root directory using file upload control as as shown below:
Create New Folder in Root directory of SharePoint Web application as shown in below screen shot.
Example: I have created a folder named "GnIExcelFiles" in root path.
Root Path: C:\inetpub\wwwroot\wss\VirtualDirectories\41417
Here 41417 is port no of my Share Point web application in , check which is the port number of your web application and create new folder as described.
Then Change the code as shown below:
string uploadexcelfile = Path.GetFileName(uploadfile.PostedFile.FileName); uploadfile.PostedFile.SaveAs(Server.MapPath("~/GnIExcelFiles/") + uploadexcelfile);
string fileName = Server.MapPath("~/GnIExcelFiles/") + uploadexcelfile;
For Reference:
I resolved my issue using above small piece of Code :)
Give A try , It will work
Thanks for Reading !
Kiny!
I have faced same Issue when uploading excel file into SharePoint list:
Problem:
Before resolving this issue,I was directly browsing the excel file from local system.When i click on upload button, I keep on getting Error "The Microsoft Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data "
I was reading excel file using file upload control as shown below:
if (!uploadfile.HasFile)
{
ltrlMsg.Text = "Please select a valid Excel File";
return;
}
try
{
//reading file from file upload control.
string fileName = uploadfile.PostedFile.FileName;
//Some code goes here
}
catch (Exception Ex1)
{
ltrlMsg.Text = Ex1.Message;
}
For Reference:
Solution:
Then am storing excel file in root directory then reading file path from root directory using file upload control as as shown below:
Create New Folder in Root directory of SharePoint Web application as shown in below screen shot.
Example: I have created a folder named "GnIExcelFiles" in root path.
Root Path: C:\inetpub\wwwroot\wss\VirtualDirectories\41417
Here 41417 is port no of my Share Point web application in , check which is the port number of your web application and create new folder as described.
Then Change the code as shown below:
string uploadexcelfile = Path.GetFileName(uploadfile.PostedFile.FileName); uploadfile.PostedFile.SaveAs(Server.MapPath("~/GnIExcelFiles/") + uploadexcelfile);
string fileName = Server.MapPath("~/GnIExcelFiles/") + uploadexcelfile;
For Reference:
I resolved my issue using above small piece of Code :)
Give A try , It will work
Thanks for Reading !
Kiny!
No comments:
Post a Comment