473,383 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 8680
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
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
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
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
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
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
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
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
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
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?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.