本文整理汇总了C#中Dir.TryGetFile方法的典型用法代码示例。如果您正苦于以下问题:C# Dir.TryGetFile方法的具体用法?C# Dir.TryGetFile怎么用?C# Dir.TryGetFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dir
的用法示例。
在下文中一共展示了Dir.TryGetFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstallOrUninstall
public override bool InstallOrUninstall()
{
string oldCustom = Installed ? App.PathCustom : App.PathCustom_;
string newCustom = Installed ? App.PathCustom_ : App.PathCustom;
Dir oldDir = new Dir(oldCustom);
Dir newDir = new Dir(newCustom);
string tmp;
List<string> files = new List<string>();
var p = _Path.GetFileNameWithoutExtension(Path) + ".";
string newPath = _Path.Combine(newCustom, _Path.GetFileName(Path));
foreach (string s in oldDir.Files)
{
if (s.StartsWith(p, StringComparison.OrdinalIgnoreCase))
{
if (newDir.TryGetFile(s, out tmp))
return false;
files.Add(s);
}
}
if (files.Count == 0)
return false;
try
{
foreach (string s in files)
File.Move(_Path.Combine(oldCustom, s), _Path.Combine(newCustom, s));
Path = newPath;
Installed = !Installed;
return true;
}
catch
{
}
return false;
}
示例2: Rename
public override bool Rename(string name)
{
string custom = Installed ? App.PathCustom : App.PathCustom_;
Dir dir = new Dir(custom);
string tmp;
List<Tuple<string, string>> files = new List<Tuple<string, string>>();
string p = Name + ".";
foreach (string s in dir.Files)
{
if (s.StartsWith(p, StringComparison.OrdinalIgnoreCase))
{
string newFile = name + "." + s.Substring(p.Length);
if (dir.TryGetFile(newFile, out tmp))
return false;
files.Add(Tuple.Create(_Path.Combine(custom, s), _Path.Combine(custom, newFile)));
}
}
if (files.Count == 0)
return false;
try
{
foreach (var x in files)
File.Move(x.Item1, x.Item2);
Name = name;
lblName.Text = name + new string(' ', 30);
return true;
}
catch
{
}
return false;
}
示例3: Load
public override void Load()
{
Dir dir = new Dir(new FileInfo(Path).Directory.FullName);
string tmp;
if (dir.TryGetFile(_Path.GetFileNameWithoutExtension(Path) + ".plugin.xml", out tmp))
LoadXml(tmp, false);
}
示例4: Load
public override void Load()
{
Dir dir = new Dir(Path);
string tmp;
if (dir.TryGetFile("thumbnail.png", out tmp) || dir.TryGetFile("thumbnail40.png", out tmp))
{
try
{
pluginImage.Image = Image.FromFile(tmp);
}
catch { }
}
else
{
pluginImage.Image = noImage;
}
if (dir.TryGetFile("mod.xml", out tmp))
{
pluginDotXmlPath = "mod.xml";
LoadXml(tmp);
}
else if (dir.TryGetFile("data.txt", out tmp))
{
ProcessDataTxt(File.ReadAllText(tmp));
}
if (dir.TryGetFile("readme.md", out tmp) || dir.TryGetFile("readme.txt", out tmp))
{
readmePath = tmp;
btnReadme.Visible = true;
}
if (dir.TryGetFile("faq.md", out tmp) || dir.TryGetFile("faq.txt", out tmp))
{
faqPath = tmp;
btnFaq.Visible = true;
}
if (dir.TryGetFile("changelog.md", out tmp) || dir.TryGetFile("changelog.txt", out tmp))
{
changelogPath = tmp;
btnChangelog.Visible = true;
}
}