Click here to Skip to main content
15,886,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in my windows application i want to fill gridview on page load from excel file,for this
i use conncetion string for specifying excel file location. but when i change my .exe location,i can't get that excel file name, means file not get because of location not found.
so how to specify just name of excel file in connection string and it's full path is detected by ~ sign which we make in property windows settings, is this possible in code(c#)?

select file in connection string like filename.xls without specifing full path like
D:\\myfolder\\filename.xls
Posted
Updated 6-Oct-15 0:56am
v3

1 solution

Why not simply use Path.GetFileName("D:\\myfolder\\filename.xls")?
https://msdn.microsoft.com/en-us/library/system.io.path.getfilename%28v=vs.110%29.aspx[^]

Good luck!
 
Share this answer
 
Comments
Member 11922776 6-Oct-15 7:18am    
if i dont wan't to specify directory name i.e. "D:\... " directly just file name filename.xls @E.F.Nijboer
E.F. Nijboer 7-Oct-15 3:46am    
But then the file must be in the same directory as the running program or it must be able to find it in one of the directories in the PATH variable.

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