473,566 Members | 2,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I change the current path for OpenFileDialog ?

I want to change the current path in the OpenFileDialog in runtime. When the
user presses OK-button I'm checking the selected path if it's valid for my
application. If it's not valid I want to set the path to a valid one in the
FileOk-event and set the e.Cancel = true.
Mar 31 '08 #1
5 4978
On Mar 31, 10:39*am, Per <P...@discussio ns.microsoft.co mwrote:
I want to change the current path in the OpenFileDialog in runtime. When the
user presses OK-button I'm checking the selected path if it's valid for my
application. If it's not valid I want to set the path to a valid one in the
FileOk-event and set the e.Cancel = true.
Can't you use Reset() or InitialDirector y() method?
Set a valid initial directory and on invalid path perform a reset() on
the file dialog.
Mar 31 '08 #2


"CSharper" wrote:
On Mar 31, 10:39 am, Per <P...@discussio ns.microsoft.co mwrote:
I want to change the current path in the OpenFileDialog in runtime. When the
user presses OK-button I'm checking the selected path if it's valid for my
application. If it's not valid I want to set the path to a valid one in the
FileOk-event and set the e.Cancel = true.

Can't you use Reset() or InitialDirector y() method?
Set a valid initial directory and on invalid path perform a reset() on
the file dialog.
When I do this operation I want the dialog to update and to show the path
that I'm setting in the method that handles the FileOk-event. If I performs a
reset the dialog is not updated to the right path it stays on the wrong path.

Apr 1 '08 #3
On Apr 1, 3:15*am, Per <P...@discussio ns.microsoft.co mwrote:
"CSharper" wrote:
On Mar 31, 10:39 am, Per <P...@discussio ns.microsoft.co mwrote:
I want to change the current path in the OpenFileDialog in runtime. When the
user presses OK-button I'm checking the selected path if it's valid for my
application. If it's not valid I want to set the path to a valid one in the
FileOk-event and set the e.Cancel = true.
Can't you use Reset() or InitialDirector y() method?
Set a valid initial directory and on invalid path perform a reset() on
the file dialog.

When I do this operation I want the dialog to update and to show the path
that I'm setting in the method that handles the FileOk-event. If I performs a
reset the dialog is not updated to the right path it stays on the wrong path.
I see your problem. Only way you can do this to make the open dialog
not to validate the the directory exists or not, this can be done by
either one of them. First one for directory validation and second one
is file validation.

openFileDialog1 .CheckPathExist s = false;
openFileDialog1 .CheckFileExist s = false;

by default both are set to true;
Apr 1 '08 #4
This still did not help. The dialog do not uppdate and show the path that I
set in my event handler for the OK button.

"CSharper" wrote:
On Apr 1, 3:15 am, Per <P...@discussio ns.microsoft.co mwrote:
"CSharper" wrote:
On Mar 31, 10:39 am, Per <P...@discussio ns.microsoft.co mwrote:
I want to change the current path in the OpenFileDialog in runtime. When the
user presses OK-button I'm checking the selected path if it's valid for my
application. If it's not valid I want to set the path to a valid one in the
FileOk-event and set the e.Cancel = true.
Can't you use Reset() or InitialDirector y() method?
Set a valid initial directory and on invalid path perform a reset() on
the file dialog.
When I do this operation I want the dialog to update and to show the path
that I'm setting in the method that handles the FileOk-event. If I performs a
reset the dialog is not updated to the right path it stays on the wrong path.

I see your problem. Only way you can do this to make the open dialog
not to validate the the directory exists or not, this can be done by
either one of them. First one for directory validation and second one
is file validation.

openFileDialog1 .CheckPathExist s = false;
openFileDialog1 .CheckFileExist s = false;

by default both are set to true;
Apr 2 '08 #5
On Apr 2, 7:47*am, Per <P...@discussio ns.microsoft.co mwrote:
This still did not help. The dialog do not uppdate and show the path that I
set in my event handler for the OK button."CSharpe r" wrote:
On Apr 1, 3:15 am, Per <P...@discussio ns.microsoft.co mwrote:
"CSharper" wrote:
On Mar 31, 10:39 am, Per <P...@discussio ns.microsoft.co mwrote:
I want to change the current path in the OpenFileDialog in runtime.. When the
user presses OK-button I'm checking the selected path if it's valid for my
application. If it's not valid I want to set the path to a valid one in the
FileOk-event and set the e.Cancel = true.
Can't you use Reset() or InitialDirector y() method?
Set a valid initial directory and on invalid path perform a reset() on
the file dialog.
When I do this operation I want the dialog to update and to show the path
that I'm setting in the method that handles the FileOk-event. If I performs a
reset the dialog is not updated to the right path it stays on the wrong path.
I see your problem. *Only way you can do this to make the open dialog
not to validate the the directory exists or not, this can be done by
either one of them. First one for directory validation and second one
is file validation.
openFileDialog1 .CheckPathExist s = false;
*openFileDialog 1.CheckFileExis ts = false;
by default both are set to true;
With the change I suggested, when user press ok button, even if the
file or directory is bad, it should close the fie dialog and you have
to validate the data yourself and if the data is bad show the file
dialog again.
My question, when you press the open button, did the window close or
did it show the error again?

If you have the code, please send it and let me have a look.
Thanks.
Apr 2 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6984
by: Ed P. | last post by:
Hello, I have an application that uses an access database that is stored in my computer. I would like to set up a OpenFileDialog object to be able to select the source of this database (i.e. c:\database.mdb). If I move the database to another location I would like to change the path to that other location. Once I change the location, I would...
5
1660
by: Webbyz | last post by:
Using vb.net Hello. Here is the problem that I am having. I have a program which makes a copy of my working database (wasa.mdb) and saves it to another folder (/bin/backup/) with the filename (9-27-2005,1210PM.mdb) *Note This Is The Current System Date And Time Of The Save.* I would like to have the function where when the user selects...
1
2324
by: Shilpa | last post by:
Hi, I have a OpenFileDialog on my windows form whose filter is *.*. I want the users to be able to further filter the files by giving *.doc or *.zip etc in the "file name" field of the dialog (Just like it happens in the open file dialog of MS Word) Currently, if the user enters a wild card character in the file name field, it is throwing...
3
5766
by: Jason | last post by:
Hi, I am developing .NET 1.1 desktop application, I want to pop up a OpenFileDialog that has a large Width and Height. However, there is no accessible OpenFileDialog.Width and OpenFileDialog.Height or OpenFileDialog.Size to set. So how to change the size of the dialog once it is poped up? Thanks,
3
3179
by: Chris Mellon | last post by:
This appears to be a change in behavior from Python 2.4 to Python 2.5, which I can't find documented anywhere. It may be windows only, or related to Windows behavior. In 2.4, the current directory (os.curdir) was on sys.path. In 2.5, it appears to be the base directory of the running script. For example, if you execute the file testme.py in...
6
3144
by: kimiraikkonen | last post by:
Hello, I have a listbox and folder browser control. I need to display all .mp3 files' pathes into listbox. It was Ok with openfiledialog but how can list all .mp3 extension- having files into my listbox using folder browser control. A sample code would be great.
2
2415
by: Tim Kelley | last post by:
I have a project that includes images as part of the project. I have a grid (Infragistics) with a button that the user clicks and it brings up a file open dialog that is used to browse to a file so the path can be saved in the grid. After the dialog is closed the program cannot find any of the images that are part of the project. I believe...
2
4711
by: MikeY | last post by:
Hi everyone, I"m having a problem with the OpenFileDialog() changing my path to save to my .resources file. I'm a bit baffled why this is happening, even when I set the OpenFileDialog back to the inital directory where the .resource file resides. What I am trying to do is get the location of my database and save it to string format in...
6
23122
by: SpreadTooThin | last post by:
After I select a file with the OpenFileDialog, I get the file name with .FileName, but I want to know the drive and path where that file is. What function, method, class can I use in C# to get the drive and path?
0
8109
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7645
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2085
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1202
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.