open file directory
-
This is probably a newbie question and I am just not getting it today but... I just want to open a file directory so that the user can open a text file but I dont need to use it in the program. The main form has a button called 'LogFiles' and when the user presses it, I just want it to open the directory and do nothing else. I was using OpenFileDialog but that is stopping execution until a file is chosen. Am i missing something obvious. Thanks
-
This is probably a newbie question and I am just not getting it today but... I just want to open a file directory so that the user can open a text file but I dont need to use it in the program. The main form has a button called 'LogFiles' and when the user presses it, I just want it to open the directory and do nothing else. I was using OpenFileDialog but that is stopping execution until a file is chosen. Am i missing something obvious. Thanks
-
Thanks for the reply, I looked at the folderbrowserdialog as you suggested and it seems as if it does the same thing. I cannot do anything else on the main form until i select a folder or press cancel. That is not exactly what I was going for. Instead of putting a shortcut on the desktop the the application log file, I wanted to open the folder from a button on the front panel. If the folder stays open in the background, the application doesnt care. Is this not possible.
-
Thanks for the reply, I looked at the folderbrowserdialog as you suggested and it seems as if it does the same thing. I cannot do anything else on the main form until i select a folder or press cancel. That is not exactly what I was going for. Instead of putting a shortcut on the desktop the the application log file, I wanted to open the folder from a button on the front panel. If the folder stays open in the background, the application doesnt care. Is this not possible.
-
I guess you want to the browse to the some path when LogFiles button is clicked. You need to set SelectedPath property FolderBrowserDialog in button click event. Isn't it
yeah thats what I want but I was hoping it could display in the background. Both the folderbrowse and openfile dialog open as modal, it seems, preventing me from doing anything else on the form. I was hoping maybe the folder could open and just sit in background in case the user needed to open one of the files at a later time. I thought there might be a way to do it that didnt require opening an actual file/folder from within the code. Is that not typical?
-
This is probably a newbie question and I am just not getting it today but... I just want to open a file directory so that the user can open a text file but I dont need to use it in the program. The main form has a button called 'LogFiles' and when the user presses it, I just want it to open the directory and do nothing else. I was using OpenFileDialog but that is stopping execution until a file is chosen. Am i missing something obvious. Thanks
Hi, I see three ways of getting a look at a directory: 1. use an existing folderbrowser dialog; since it is a dialog, it will have modal behavior. 2. open up the folder using Windows Explorer; use
Process.Start(fileName)
to make it happen. This launches a separate process and will behave completely independently of your app. 3. write your own Form that somehow displays folder contents, and Show() it modelessly. :)Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
-
yeah thats what I want but I was hoping it could display in the background. Both the folderbrowse and openfile dialog open as modal, it seems, preventing me from doing anything else on the form. I was hoping maybe the folder could open and just sit in background in case the user needed to open one of the files at a later time. I thought there might be a way to do it that didnt require opening an actual file/folder from within the code. Is that not typical?
-
Hi, I see three ways of getting a look at a directory: 1. use an existing folderbrowser dialog; since it is a dialog, it will have modal behavior. 2. open up the folder using Windows Explorer; use
Process.Start(fileName)
to make it happen. This launches a separate process and will behave completely independently of your app. 3. write your own Form that somehow displays folder contents, and Show() it modelessly. :)Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
Thanks Luc, by background, what I really meant was, independent of my application. I wanted an explorer window to stay open regardless of whether or not a file was chosen. I just couldnt explain myself properly. Process.Start was just what I was looking for!
-
This is probably a newbie question and I am just not getting it today but... I just want to open a file directory so that the user can open a text file but I dont need to use it in the program. The main form has a button called 'LogFiles' and when the user presses it, I just want it to open the directory and do nothing else. I was using OpenFileDialog but that is stopping execution until a file is chosen. Am i missing something obvious. Thanks
Hi, I think that you want to open a Windows Explorer window at a particular directory for the convenience of your users, correct? In which case use System.Diagnostics.Process.Start(pathname) [EDITED typo] The Start method has many overloads and this simple one uses the associated application to open pathname. So as an example, if pathname is d:\logfile.txt then Notepad is used to open the file d:\logfile.txt. What you might not have realised is that directories are associated with Explorer. As a consequence if pathname is a directory, e.g. d:\logfiles then the Start method will open an Explorer windows at the d:\logfiles directory. Alan. [EDIT: Like Luc said a few minutes ago]
modified on Wednesday, March 18, 2009 4:09 PM
-
Hi, I think that you want to open a Windows Explorer window at a particular directory for the convenience of your users, correct? In which case use System.Diagnostics.Process.Start(pathname) [EDITED typo] The Start method has many overloads and this simple one uses the associated application to open pathname. So as an example, if pathname is d:\logfile.txt then Notepad is used to open the file d:\logfile.txt. What you might not have realised is that directories are associated with Explorer. As a consequence if pathname is a directory, e.g. d:\logfiles then the Start method will open an Explorer windows at the d:\logfiles directory. Alan. [EDIT: Like Luc said a few minutes ago]
modified on Wednesday, March 18, 2009 4:09 PM
Hi, I dont think i understand correctly. 1. Yes, I do want to open an explorer window, not a file as your example demonstrates 2. I cannot find System.Diagnostics.Start
-
Hi, I dont think i understand correctly. 1. Yes, I do want to open an explorer window, not a file as your example demonstrates 2. I cannot find System.Diagnostics.Start
Ah, my mistake. If I had written System.Diagnostics.Process.Start, the original post might have made more sense. In the System.Diagnostics namespace is the Process class and that has a Start method. If you pass a directory path to the Start method it will open an Explorer window at that path. Alan.
modified on Wednesday, March 18, 2009 3:59 PM
-
I am cofused with Background. If you dont want to show to dialog box than you need to save your log file path in some variable. Nothing else
What you want to do is utilize the background worker process. This will allow you to open the dialog in its own thread not affecting the main form. I have done this for an application for saving or zipping files. I found that if i did not use the background worker process my form would lock up until the save/zip was completed. I found this article very helpful. http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx[^] Hope that helps. Matthew Vass QA Analyst mvass@hostmysite.com http://www.hostmysite.com?utm_source=bb[^]
-
Ah, my mistake. If I had written System.Diagnostics.Process.Start, the original post might have made more sense. In the System.Diagnostics namespace is the Process class and that has a Start method. If you pass a directory path to the Start method it will open an Explorer window at that path. Alan.
modified on Wednesday, March 18, 2009 3:59 PM
ah Got it now... Thanks again for everyone's help