Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am using excel file in my project. I included the file path but it showing error "'~/Data/File.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct. If you are trying to open the file from your list of most recently used files, make sure that the file has not been renamed, moved, or deleted."

C#
o.Open("~/Data/File.xls");



someone give solution for this problem..


Regards
Karthik.R
Posted
Updated 6-Jan-15 1:55am
v2

1 solution

We don't know your setup. First, set the path explicitly (use absolute path) to see you have access rights. Then use relative, but use

Try using Path.GetFullPath ("~/Data/File.xls") to see where it maps


C#
Server.MapPath("~/Data/File.xls")
- this could (maybe) resolve your problem - THIS ASSUMES WEB APP although you didn't specify it :)

If this helps please take time to accept the solution. Thank you.
 
Share this answer
 
v3
Comments
Karthik Ravi 23-Dec-14 4:07am    
Absolute path is working fine, I am doing this project coded ui not web application..
Sinisa Hajnal 23-Dec-14 4:17am    
Then the problem remains - your relative path doesn't map properly to your absolute path. See how you can resolve ~path.
Karthik Ravi 23-Dec-14 4:23am    
I think path format is right, the property which i need to set is wrong...
Sinisa Hajnal 23-Dec-14 4:35am    
What is your directory structure? Why do you think the path is right? What kind of application are you making (winforms, wpf, something else...)?
Karthik Ravi 23-Dec-14 4:59am    
Directory Structure : Data/File.xls
path i think coreect : ~/Data/File.xls
application : coded ui

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900