I have written a web app using MVC 4 c#. I present to the user a form with an input type=file. This allows the user to browse folders for the excel file they want to upload. The filename with the entire path is returned to my controller which I use as the data source in the connection string.
mCon = new System.Data.OleDb.OleDbConnection();
mCon.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;data source=" + pathOfFile + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES;READONLY=YES\";");
pathOfFile contains this:
I then do mCon.Open()
The G drive is a mapped network drive.
This works fine when I run it locally within Visual Studio. However, after I publish this web app to my server things change. I run the applicaion from my pc and when it gets to the part to open the connection I get this:
'G:\IT\EnterpriseApplications\Code\WebApps\FileUpload\LoadWells_Generwell.xlsx' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
Drive G on the server is also a mapped network drive and I can see the file using windows explorer on the server just fine.
What am I doing wrong?