console application need call open dialog box to let the user select a file .. Is that possible??

I am thinking of developing a console application and my dilema right now is how to call the open dialog box from a console application, once after user select a file, i need do some data manipulation based on the user selected filename, i know if i use a windows form applicaton, the above task can be achieved freaking easy, but it was very unfortunate that
my boss asked to develoe a console application to achieve the above task..

Is that possible???

 
nyee84Asked:
Who is Participating?
 
Bob LearnedConnect With a Mentor Commented:
Sure, just do this:

1) Add a reference to System.Windows.Forms.dll to the project

2) Use some code similar to this:

Imports System.Windows.Forms

Module Module1

  Sub Main()

    Dim dialog As New OpenFileDialog

    dialog.ShowDialog()

  End Sub

End Module

Bob
0
 
nyee84Author Commented:
I got an error message when adding reference to windows.forms.dll

A referece to System.Windows.Forms.dll could not be added. Converting the type library to a .NET assembly failed. Type Library System_Windows_Forms was exported from a CLR assembly and cannot be re-imported as CLR assembly.

What does it mean>> How to resolve it?
0
 
Bob LearnedCommented:
Whoa! Where are getting that from?  What tab were you on on the Add Reference dialog?  Were you on the COM tab?

Bob
0
 
nyee84Author Commented:
Hi Bob,

I have selected COM tab and selected " System.Windows.Forms.dll" and when i tried click ok i have encountered the above mentioned error message..

Nyee
0
 
Bob LearnedCommented:
Nyee,

That's what I thought.  System.Windows.Forms.dll is on the .NET tab, not the COM tab.

Bob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.