OpenFileDialog

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having problems giving my dialog box the initial directory at runtime.
I can get it working if I code it at design time, does any one know why this
code wont allow me to get the initial directory from a Class at runtim.

with openfiledialog1

.InitialdDirectory = MyClass.GetDirectory

.ShowDialog()

end with
 
Ithaqua said:
I am having problems giving my dialog box the initial directory at runtime.
I can get it working if I code it at design time, does any one know why
this
code wont allow me to get the initial directory from a Class at runtim.

Error message? What's the exact problem?
 
When I use the following code to get a folder location from my Class it
allways opens the dialog box at My Documents.

MyClass
{
Folder_location = "C:\"
}

with openfiledialog1

.InitialdDirectory = MyClass.GetDirectory

.ShowDialog()

end with

How ever if I hard code it like this it opens in the specified directory

with openfiledialog1

.InitialdDirectory = "C:\"

.ShowDialog()

end with
 
When I use the following code to get a folder location from my Class it
allways opens the dialog box at My Documents.

MyClass
{
Folder_location = "C:\"
}

with openfiledialog1

.InitialdDirectory = MyClass.GetDirectory

.ShowDialog()

end with

How ever if I hard code it like this it opens in the specified directory

with openfiledialog1

.InitialdDirectory = "C:\"

.ShowDialog()

end with
 
Ithaqua said:
When I use the following code to get a folder location from my Class it
allways opens the dialog box at My Documents.

MyClass
{
Folder_location = "C:\"
}

with openfiledialog1

.InitialdDirectory = MyClass.GetDirectory

Where is 'GetDirectory' defined?
 
Ithaqua,

Forgive me that I had so smile, that it is in MyClass (although not litary I
hope because that is a keyword), does Herfried for sure know.

I think that he did more wanted to know where the information came from that
is in MyClass. (And if you checked that the information was really correct.)

Cor
 
Ithaqua said:
It is defined in MyClass.

First, 'MyClass' is a reserved keyword in VB.NET, second there might be a
bug in the implementation of the method.
 
Ithaqua said:
When I use the following code to get a folder location from my Class it
allways opens the dialog box at My Documents.

MyClass
{
Folder_location = "C:\"
}

with openfiledialog1

.InitialdDirectory = MyClass.GetDirectory

.ShowDialog()

end with

How ever if I hard code it like this it opens in the specified directory

with openfiledialog1

.InitialdDirectory = "C:\"

.ShowDialog()

end with

Can you post the code for your GetDirectory method here.... I'm guessing
the problem may be there.
 
I have checked and this returns the directory location like it should.


ReadOnly Property getDirectory()
Get

' Get the value of the private class variable in one instance
Return _directoryLocation

End Get
End Property
 
Ithaqua said:
I have checked and this returns the directory location like it should.


ReadOnly Property getDirectory()
Get

' Get the value of the private class variable in one instance
Return _directoryLocation

End Get
End Property

Although this won't solve the problem

\\\
Public ReadOnly Property Directory() As String
Get
Reurn ...
End Get
End Property
///

should be preferred.
 
Ithaqua said:
I am having problems giving my dialog box the initial directory at runtime.
I can get it working if I code it at design time, does any one know why
this
code wont allow me to get the initial directory from a Class at runtim.

with openfiledialog1

.InitialdDirectory = MyClass.GetDirectory

.ShowDialog()

end with

Shouldn't that be: .InitialDirectory without the extra "d"
 
you could try

application.startuppath

that would get the filder of where your app started

-iwdu150
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top