Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorRenderingWpf/Utils/WpfApplicationContext.cs @ 13348

Last change on this file since 13348 was 12762, checked in by aballeit, 9 years ago

#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)

File size: 1.1 KB
Line 
1using System;
2using System.IO;
3using System.Diagnostics;
4using System.Security;
5using System.Security.Permissions;
6
7namespace SharpVectors.Renderers.Utils
8{
9  public sealed class WpfApplicationContext
10  {
11    public static DirectoryInfo ExecutableDirectory
12    {
13      get
14      {
15        DirectoryInfo di;
16        try
17        {
18          FileIOPermission f = new FileIOPermission(PermissionState.None);
19          f.AllLocalFiles = FileIOPermissionAccess.Read;
20
21          f.Assert();
22
23                    di = new DirectoryInfo(Path.GetDirectoryName(
24                        System.Reflection.Assembly.GetExecutingAssembly().Location));
25        }
26        catch(SecurityException)
27        {
28          di = new DirectoryInfo(Directory.GetCurrentDirectory());
29        }
30        return di;
31      }
32    }
33
34    public static DirectoryInfo DocumentDirectory
35    {
36      get
37      {
38        return new DirectoryInfo(Directory.GetCurrentDirectory());
39      }
40    }
41
42    public static Uri DocumentDirectoryUri
43    {
44      get
45      {
46                string sUri = DocumentDirectory.FullName + "/";
47        sUri = "file://" + sUri.Replace("\\", "/");
48        return new Uri(sUri);
49      }
50    }
51  }
52}
Note: See TracBrowser for help on using the repository browser.