Search code examples
absolute-path

How to read an excel file having IIS path in ASP.NET


I have a file path in my default.aspx.cs page like this: http://localhost/data/Download/Import/Test.xlsx

I want to read this file using EFPlus library and make some changes. But I am not able to read its content and getting error like "URI Format not supported". If I read file directly from physical path then everything works fine. Below is my code snippet.

Dim newFile As New FileInfo


Solution

  • I found the solution, its not possible to get physical path of a file and read it using any library if we have URL like http://localhost/data/Download/Import/Test.xlsx. We have to give physical path of server if file is not in same directory where website code exists, only then we can read and access that file.