How do I get project folder in .NET?

  • Thread starter Thread starter astroboy
  • Start date Start date
* "astroboy said:
How do I get project folder in .NET?

Are you referring to the application path?

\\\
Imports System.IO
Imports System.Reflection
..
..
..
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
End Function
///
 
No not that I meant, I want to retrieve Project Folder or application path
location at compile time. If you go to Project-> xxx Properties->Common
Properties ->General
You would see Project folder, project file and output name in there, I would
like to get those infomation

Thx
Herfried K. Wagner said:
* "astroboy said:
How do I get project folder in .NET?

Are you referring to the application path?

\\\
Imports System.IO
Imports System.Reflection
.
.
.
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
End Function
///
 
hum strange
what do you want to do with that info?


but here some code you can use
you have to dig in it, won't do exactly what you need, but it's already a
part of it


Imports EnvDTE 'add reference:
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\envdte.dll"

Public Class Class1

Public Shared Sub main()

Dim DTE As EnvDTE.DTE =
System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE")
Dim vbProjects As Projects = DirectCast(DTE.GetObject("VBProjects"),
Projects)
Dim aProject As Project
For Each aProject In vbProjects
MsgBox(aProject.FullName)
Dim x As System.Collections.IEnumerator =
aProject.Properties.GetEnumerator()
Dim pr As [Property]
Dim msg As String = ""

While (x.MoveNext)
pr = DirectCast(x.Current, [Property])
msg &= pr.Name & vbCrLf

End While
MsgBox(msg)
Next
End Sub
End Class






astroboy said:
No not that I meant, I want to retrieve Project Folder or application path
location at compile time. If you go to Project-> xxx Properties->Common
Properties ->General
You would see Project folder, project file and output name in there, I would
like to get those infomation

Thx
Herfried K. Wagner said:
* "astroboy said:
How do I get project folder in .NET?

Are you referring to the application path?

\\\
Imports System.IO
Imports System.Reflection
.
.
.
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
End Function
///
 
Hi Dominique,

Change the tittlebar of his project I think

:-)))

I really do not know otherwise I had answered you of course, but could not
resist this one.

Cor
 
well he was lucky, found that stuff while searching info to make my
windowtitle change
somewhere there is a MainWindow.Caption property which is the windowtitle of
visual studio

reading goes well but setting the property throws an exception
found some info where i read between the lines you can only read the caption
property for mainwindow
(for other windows it should work)

so i'm doomed i think
 
Back
Top