main

mattermost/focalboard

Last updated at: 29/12/2023 09:43

Utils.cs

TLDR

This file contains a class named Utils with a static method GetAppFolder(). The method returns the path to the application's folder.

Methods

GetAppFolder()

This method returns a string representing the path to the application's folder. It first attempts to retrieve the folder path using the Windows.ApplicationModel.Package.Current.InstalledLocation.Path property. If that fails, indicating that the application is not a UWP app, it retrieves the folder path using System.Reflection.Assembly.GetExecutingAssembly().Location and Path.GetDirectoryName().

Classes

No classes in this file

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
using System.IO;

namespace Focalboard {
    static class Utils {
        public static string GetAppFolder() {
            string appFolder;

            try {
                appFolder = Windows.ApplicationĀ­Model.Package.Current.InstalledĀ­Location.Path;
            } catch {
                // Not a UWP app
                string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
                appFolder = Path.GetDirectoryName(appPath);
            }

            return appFolder;
        }
    }
}