Click here to Skip to main content
15,887,273 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello. I am creating Windows Form project with custom file extension.
What I want is when I double click an icon with the new file extension, to get the filename and filepath.
Example:
C:\TestDB\NewDatabase2\NewDatabase2.abc

I need to get the path:
C:\TestDB\NewDatabase2

I need also the filename:
NewDatabase2.abc


What I have tried:

I have tried things like:
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase

System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)

I am only getting the .exe name.
Posted
Updated 23-May-17 2:56am
Comments
F-ES Sitecore 23-May-17 5:17am    
Have a look at the methods on the Path object

Path.GetFileName

Path.GetFileNameWithoutExtension
stivanov 23-May-17 8:17am    
Yes, but you need to provide a string with the path. I am not able to get the double clicked icon name on application startup.

Use FileInfo Class Of system.IO Namespace.
 
Share this answer
 

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