Rev | Line | |
---|
[12762] | 1 | using System;
|
---|
| 2 | using System.Diagnostics;
|
---|
| 3 | using System.IO;
|
---|
| 4 | using System.Security;
|
---|
| 5 | using System.Security.Permissions;
|
---|
| 6 |
|
---|
| 7 | namespace SharpVectors.Renderers.Forms
|
---|
| 8 | {
|
---|
| 9 | public class SvgApplicationContext
|
---|
| 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 FileInfo(System.Windows.Forms.Application.ExecutablePath).Directory;
|
---|
| 24 | }
|
---|
| 25 | catch(SecurityException)
|
---|
| 26 | {
|
---|
| 27 | di = new DirectoryInfo(Directory.GetCurrentDirectory());
|
---|
| 28 | }
|
---|
| 29 | return di;
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | public static DirectoryInfo DocumentDirectory
|
---|
| 34 | {
|
---|
| 35 | get
|
---|
| 36 | {
|
---|
| 37 | return new DirectoryInfo(Directory.GetCurrentDirectory());
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | public static Uri DocumentDirectoryUri
|
---|
| 42 | {
|
---|
| 43 | get
|
---|
| 44 | {
|
---|
| 45 | string sUri = DocumentDirectory.FullName + "/";
|
---|
| 46 | sUri = "file://" + sUri.Replace("\\", "/");
|
---|
| 47 | return new Uri(sUri);
|
---|
| 48 | }
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
| 51 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.