473,508 Members | 2,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting InitialDirectory

Does anybody know how to set the InitialDirectory Property for Open or SaveFileDialog? Nothing I do seems to open either in the directory I specify. If I'm way off here does anybody know how to open these dialogs to display a specific directory

Here's the code I'm using for the InitialDirectory specification. I've also tried specifying this in the SaveFileDialog1 property window.

Dim SaveFileDialog1 As New SaveFileDialo
SaveFileDialog1.InitialDirectory = "c:\My Documents

Any help would be appreciated

Thanks
Jul 21 '05 #1
2 8685
Chuck,
Which OS are you on?

Does "C:\My Documents" actually exist?

I normally use code similar to:

Dim dialog As New SaveFileDialog
dialog.InitialDirectory =
Environment.GetFolderPath(Environment.SpecialFolde r.Personal)
dialog.RestoreDirectory = True
dialog.Filter = "My files(*.my)|*.my|All files (*.*)|*.*"
dialog.FilterIndex = 1
dialog.DefaultExt = "my"
If dialog.ShowDialog() = DialogResult.OK Then
Dim stream As Stream = dialog.OpenFile()
Serialize(stream, document)
stream.Close()
End If
Which will set the initial directory to the "My Documents" folder for the
current user independent of the OS version.

Hope this helps
Jay

"Chuck" <an*******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
Does anybody know how to set the InitialDirectory Property for Open or SaveFileDialog? Nothing I do seems to open either in the directory I
specify. If I'm way off here does anybody know how to open these dialogs to
display a specific directory?
Here's the code I'm using for the InitialDirectory specification. I've also tried specifying this in the SaveFileDialog1 property window.
Dim SaveFileDialog1 As New SaveFileDialog
SaveFileDialog1.InitialDirectory = "c:\My Documents"

Any help would be appreciated.

Thanks

Jul 21 '05 #2
I am a C# programmer so apologies if this is irrelevant: do you need to
escape the "\"? In C#, you would code it in one of these ways:

1) SaveFileDialog1.InitialDirectory = "c:\\My Documents";

2) SaveFileDialog1.InitialDirectory = @"c:\My Documents";

Not sure about VB.NET though . . .

Kent

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Chuck,
Which OS are you on?

Does "C:\My Documents" actually exist?

I normally use code similar to:

Dim dialog As New SaveFileDialog
dialog.InitialDirectory =
Environment.GetFolderPath(Environment.SpecialFolde r.Personal)
dialog.RestoreDirectory = True
dialog.Filter = "My files(*.my)|*.my|All files (*.*)|*.*"
dialog.FilterIndex = 1
dialog.DefaultExt = "my"
If dialog.ShowDialog() = DialogResult.OK Then
Dim stream As Stream = dialog.OpenFile()
Serialize(stream, document)
stream.Close()
End If
Which will set the initial directory to the "My Documents" folder for the
current user independent of the OS version.

Hope this helps
Jay

"Chuck" <an*******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
Does anybody know how to set the InitialDirectory Property for Open or SaveFileDialog? Nothing I do seems to open either in the directory I
specify. If I'm way off here does anybody know how to open these dialogs

to display a specific directory?

Here's the code I'm using for the InitialDirectory specification. I've

also tried specifying this in the SaveFileDialog1 property window.

Dim SaveFileDialog1 As New SaveFileDialog
SaveFileDialog1.InitialDirectory = "c:\My Documents"

Any help would be appreciated.

Thanks


Jul 21 '05 #3

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

Similar topics

6
2715
by: Niyazi | last post by:
Hi, We have and IBM AS400 and I belive the reional setting is Turkish. The IBM Client-Access for Windows that install in our PC (WIN XP SP2) set to Turkish characters. Now my PC has English...
18
18309
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
0
1742
by: Shravan | last post by:
Hi, I have a Windows Forms Custom DataGrid, which is put in a usercontrol, which on setting DataSource is setting focus to grid. The call stack for setting the focus is as follows. This is not...
2
3514
by: Derrick | last post by:
I am explicitly setting the InitialDirectory property on an OpenFileDialog, after opening, navigating to another dir, close, open again, it does not start at the InitialDirectory property I am...
2
2557
by: junlia | last post by:
Hi All, I am working on a project that acts as a bridge. It does some checking with post xml data, and then redirects the request to an appropriate page. However, we find that depends on the...
0
470
by: Chris Lane | last post by:
Hi I am not able to figure out eithier thru google or MSDN if the InitialDirectory property can be set using a UNC Path name. My thought is no since it is not working for me Does anybody out...
2
716
by: Chuck | last post by:
Does anybody know how to set the InitialDirectory Property for Open or SaveFileDialog? Nothing I do seems to open either in the directory I specify. If I'm way off here does anybody know how to open...
1
6441
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
6
10031
by: metaperl | last post by:
I would like to check the setting of this variable in our MS-SQL 2000 database. Also, is there info on what the default value of this variable is?
0
7132
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7401
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...
1
7063
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...
0
7504
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...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
432
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...

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.