1

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

2 Answers 2

1

You need to use function Server.MapPath, described here. This function generates a path relative to the root folder of your site. The input starts with a tilde ~, which means the root. I.e.

Server.MapPath("~/images")

will return a string pointing to your /images folder.

Sign up to request clarification or add additional context in comments.

2 Comments

But my file is not in same location where my website code is, its on another folder outside the website folder which is managed by virtual directory
Then don't use the tilde. Use an absolute path pointing to the virtual directory, I.e. /myvirtualdirectory/myfile.xlsx
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.