 |
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

July 29th, 2004, 08:00 AM
|
Registered User
|
|
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How to get a file's FullName/path?
By using an OpenFileDialog, I can easily get the dlg.FileName value.
But how can I get it, when I am double-clicking an existing file on my disk.I just want to open it with my own reader, not NotePad,and I need to know fileInfo.FullName.
Hope for reply!
Jansonx
|

July 29th, 2004, 08:23 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Do you mean when you are browsing a directory in windows, and you double click the file? First you need to associate the file with your application, then your application needs to be able to handle command line arguments. I believe Windows will pass you the file name you clicked on in the command line call it uses to start your application (unless it's using DDE or something like that). So your app needs to read the command line and thus get the filename from that argument.
|

July 29th, 2004, 10:00 AM
|
Registered User
|
|
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Well, I have deployed a setup project, so the file I want to open have already been associated with my reader(a MDI app). The problem is when I open my application, clicking the "open" menuItem to open an existing file, it works quite well. However, when I double click the file ,(of course it calls my app to open the file) it cann't be read correctly.
I just need the fileInfo.FullName and pass it to my Mdiparent's constructor.
Many thanks!
Jansonx
|

July 29th, 2004, 11:29 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
My point is that you are asking for fileInfo.FullName.... but the full name of what? Where are you getting the file info from if you aren't using File...Open? When you use that, the application is already running, and the file...open process provides you with the file/name. When the application is called, Windows provides the filename on the call to the application and from that you can set up the file object to read it.
Am I misunderstanding what you are asking for or do I just have no idea what I'm talking about? I work with web applications primarily so the latter is very likely, but I think I understand the principle of your goal.
|

July 29th, 2004, 10:49 PM
|
Registered User
|
|
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
eg:I created a test.doc on my disk, and wrote a sentence, "Hello World" down in the doc. By double clicking the file, Microsoft Word editor(you know it's a MDI app) is openned, and the sentence is shown in a child window. It works like this,I think: the MdiParent form first gets the path name of test.doc. Then, it passes the path name(such as: "C:\test.doc") as a parameter to its constructor. And last, the constructor creates a new child form ,copies the file content and shows the content in the child form using the passed parameter.
I just cann't get the parameter. Can you help me?
Thanks for replying!
Jansonx
|

July 30th, 2004, 09:52 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
|

July 31st, 2004, 03:12 AM
|
Registered User
|
|
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
First, I want to say thank you, thank very much! I did it.
As you have told me ,windows will provide me the parameter. I finally use arguments in main method and did my work well.
Many thanks!
Jansonx
|
|
 |