Files
@ 64ef4331f012
Branch filter:
Location: ATITD-Tools/Desert-Paint-Lab/FileUtils.cs - annotation
64ef4331f012
4.9 KiB
text/x-csharp
Update version to 1.7.15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb 234ae2144a25 234ae2144a25 234ae2144a25 234ae2144a25 234ae2144a25 234ae2144a25 234ae2144a25 234ae2144a25 234ae2144a25 f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 8c3f6ec929d6 501aa95c46d7 8c3f6ec929d6 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb 501aa95c46d7 501aa95c46d7 8c3f6ec929d6 501aa95c46d7 501aa95c46d7 8c3f6ec929d6 501aa95c46d7 501aa95c46d7 501aa95c46d7 f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb 501aa95c46d7 f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 501aa95c46d7 f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb f28757bb21cb 991c95f4da74 991c95f4da74 991c95f4da74 991c95f4da74 991c95f4da74 991c95f4da74 991c95f4da74 991c95f4da74 991c95f4da74 991c95f4da74 991c95f4da74 991c95f4da74 f28757bb21cb f28757bb21cb f28757bb21cb | using System;
namespace DesertPaintLab
{
public class FileUtils
{
public FileUtils()
{
}
public static string AppDataPath
{
get {
return System.IO.Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"DesertPaintLab");
}
}
public static string FindApplicationResourceDirectory(string dirname)
{
string dirPath = System.IO.Path.Combine(
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
dirname);
if (System.IO.Directory.Exists(dirPath))
{
return dirPath;
}
dirPath = System.IO.Path.Combine(
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
"data",
dirname);
if (System.IO.Directory.Exists(dirPath))
{
return dirPath;
}
// try "Resources" in case this is a Mac app bundle
dirPath = System.IO.Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.Resources), "data", dirname);
if (System.IO.Directory.Exists(dirPath))
{
return dirPath;
}
// try "Resources" in case this is a Mac app bundle
dirPath = System.IO.Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.Resources), dirname);
if (System.IO.Directory.Exists(dirPath))
{
return dirPath;
}
dirPath = System.IO.Path.Combine(
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
"Resources", "data",
dirname);
if (System.IO.Directory.Exists(dirPath))
{
// not found
return dirPath;
}
dirPath = System.IO.Path.Combine(
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
"Resources",
dirname);
if (!System.IO.Directory.Exists(dirPath))
{
// not found
dirPath = null;
}
return dirPath;
}
public static string FindApplicationResourceFile(string filename)
{
// start with the location of the executable
string filePath = System.IO.Path.Combine(
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
filename);
if (!System.IO.File.Exists(filePath))
{
filePath = System.IO.Path.Combine(
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
"data",
filename);
}
if (!System.IO.File.Exists(filePath))
{
// try "Resources/data" in case this is a Mac app bundle
filePath = System.IO.Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.Resources), "data", filename);
}
if (!System.IO.File.Exists(filePath))
{
// try "Resources" in case this is a Mac app bundle
filePath = System.IO.Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.Resources), filename);
}
if (!System.IO.File.Exists(filePath))
{
filePath = System.IO.Path.Combine(
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
"Resources", "data",
filename);
}
if (!System.IO.File.Exists(filePath))
{
filePath = System.IO.Path.Combine(
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
"Resources",
filename);
}
if (!System.IO.File.Exists(filePath))
{
// not found
filePath = null;
}
return filePath;
}
public static string FindNumberedFile(string baseName, string extension, string folder)
{
string filename = "";
int i = 0;
do
{
++i;
filename = System.IO.Path.Combine(folder, String.Format("{0}_{1}.{2}", baseName, i, extension));
} while (System.IO.File.Exists(filename));
return filename;
}
}
}
|