Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the WPF equivalent to "System.Windows.Forms.Application.X" for obtaining startup path, app data path, etc.?

Tags:

c#

wpf

I'm converting a windows forms application to a WPF application. Is there a way to obtain things like, Startup Path, User App Data Path, Common App Data Path, etc. without referencing System.Windows.Forms?

Previously, I used System.Windows.Forms.Application.StartupPath, but the System.Windows.Application.Current object doesn't contain the same information.

like image 549
bporter Avatar asked Aug 30 '10 19:08

bporter


People also ask

Is WPF same as Windows Forms?

Introduction. The abbreviation W.P.F simply refers to Microsoft's Windows Presentation Foundation, and WinForms is a simple concatenation of Windows Forms Applications. These are both Microsoft's Windows Applications Graphical User Interfaces that developers may use to develop Windows desktop applications.

Why we use WPF instead of Windows Forms?

Advantages of using WPF instead of Windows forms: XAML makes it easy to create and edit your GUI, and allows the work to be split between a designer (XAML) and a programmer (C#, VB.NET etc.). It allows you to make user interfaces for both Windows applications and web applications (Silverlight/XBAP).

What is the difference between WPF and Windows Form application in C#?

Windows forms are mainly based on a pixel, whereas WPF is not pixel-based, which allows the scalability of the UI part for the application. Windows forms support data binding in a limited way, whereas WPF is fully supported data binding.

What is WPF used for?

Windows Presentation Foundation (WPF) is a UI framework that creates desktop client applications. The WPF development platform supports a broad set of application development features, including an application model, resources, controls, graphics, layout, data binding, documents, and security.


2 Answers

You might want to look at System.Environment.GetFolderPath.

The values of the SpecialFolder enum are numerous:

ApplicationData
CommonApplicationData
CommonProgramFiles
Cookies
Desktop
DesktopDirectory
Favorites
History
InternetCache
LocalApplicationData
MyComputer
MyDocuments
MyMusic
MyPictures
Personal
ProgramFiles
Programs
Recent
SendTo
StartMenu
Startup
System
Templates

Is that helpful?

like image 122
Dan Tao Avatar answered Sep 28 '22 21:09

Dan Tao


this will help

for Application.StartupPath use AppDomain.CurrentDomain.BaseDirectory

http://msdn.microsoft.com/en-us/library/system.appdomain.basedirectory.aspx

like image 6
Camilo Sanchez Avatar answered Sep 28 '22 19:09

Camilo Sanchez