Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
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
 
Old July 29th, 2004, 08:00 AM
Registered User
 
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
Old July 29th, 2004, 08:23 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.
 
Old July 29th, 2004, 10:00 AM
Registered User
 
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old July 29th, 2004, 11:29 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.
 
Old July 29th, 2004, 10:49 PM
Registered User
 
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old July 30th, 2004, 09:52 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

http://www.google.com/search?hl=en&l...arguments+C%23

http://msdn.microsoft.com/library/en...rgumentspg.asp
 
Old July 31st, 2004, 03:12 AM
Registered User
 
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with path for loading Pics (app.path) Tabbasum Beginning VB 6 2 November 15th, 2007 04:57 AM
Implementing the all-path shortest path problem bitwords XSLT 1 December 6th, 2006 11:37 AM
empty a file's contents in perl crmpicco Perl 1 November 13th, 2006 08:39 AM
using app.path in database path and filename kd8con VB Databases Basics 2 October 25th, 2006 11:45 AM
Convert logical path to absolute path zoostar J2EE 1 April 15th, 2005 10:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.