本文整理汇总了C#中Pri.LongPath.DirectoryInfo类的典型用法代码示例。如果您正苦于以下问题:C# Pri.LongPath.DirectoryInfo类的具体用法?C# Pri.LongPath.DirectoryInfo怎么用?C# Pri.LongPath.DirectoryInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pri.LongPath.DirectoryInfo类属于命名空间,在下文中一共展示了Pri.LongPath.DirectoryInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EnumDirectory
public EnumDirectory(DirectoryInfo directoryInfo, string pattern = null)
{
this.directoryInfo = directoryInfo;
if (pattern == null)
pattern = "*.*";
this.directoryEnum = directoryInfo.EnumerateDirectories(pattern).GetEnumerator();
}
开发者ID:labeuze,项目名称:source,代码行数:7,代码来源:Directory.cs
示例2: Main
static void Main(string[] args)
{
//Works fine
System.IO.DirectoryInfo sysDirectory = new System.IO.DirectoryInfo("C:\\TEST");
sysDirectory.EnumerateFiles();
//Does not compile:
//'Pri.LongPath.DirectoryInfo' does not contain a definition for 'EnumerateFiles'
//and no extension method 'EnumerateFiles' accepting a first argument of type
//'Pri.LongPath.DirectoryInfo' could be found (are you missing a using directive or an assembly reference?)
Pri.LongPath.DirectoryInfo longDirectory = new Pri.LongPath.DirectoryInfo("C:\\TEST");
longDirectory.EnumerateFiles();
}
开发者ID:FuchsiaSoft,项目名称:LongPathTest,代码行数:13,代码来源:Program.cs
示例3: DirectorySize
static long DirectorySize(DirectoryInfo dInfo, bool includeSubDir)
{
// Enumerate all the files
long totalSize = dInfo.EnumerateFiles().Sum(file => file.Length);
// If Subdirectories are to be included
if (includeSubDir)
{
// Enumerate all sub-directories
totalSize += dInfo.EnumerateDirectories().Sum(dir => DirectorySize(dir, true));
}
return totalSize;
}
开发者ID:labeuze,项目名称:source,代码行数:13,代码来源:DirSize.cs
示例4: TestSetLastWriteTimeUtc
public void TestSetLastWriteTimeUtc()
{
var tempLongPathFilename = Path.Combine(uncDirectory, Path.GetRandomFileName());
Directory.CreateDirectory(tempLongPathFilename);
try
{
DateTime dateTime = DateTime.UtcNow.AddDays(1);
Directory.SetLastWriteTimeUtc(tempLongPathFilename, dateTime);
var fi = new DirectoryInfo(tempLongPathFilename);
Assert.AreEqual(fi.LastWriteTimeUtc, dateTime);
}
finally
{
Directory.Delete(tempLongPathFilename);
}
}
开发者ID:HMartyrossian,项目名称:LongPath,代码行数:17,代码来源:UncDirectoryTests.cs
示例5: TestSetCreationTime
public void TestSetCreationTime()
{
var tempLongPathFilename = Path.Combine(uncDirectory, Path.GetRandomFileName());
Directory.CreateDirectory(tempLongPathFilename);
Assert.IsTrue(Directory.Exists(tempLongPathFilename));
try
{
DateTime dateTime = DateTime.Now.AddDays(1);
Directory.SetCreationTime(tempLongPathFilename, dateTime);
var di = new DirectoryInfo(tempLongPathFilename);
Assert.AreEqual(di.CreationTime, dateTime);
}
finally
{
Directory.Delete(tempLongPathFilename);
}
}
开发者ID:HMartyrossian,项目名称:LongPath,代码行数:18,代码来源:UncDirectoryTests.cs
示例6: TestGetLastWriteTime
public void TestGetLastWriteTime()
{
var tempLongPathFilename = Path.Combine(longPathDirectory, Path.GetRandomFileName());
Directory.CreateDirectory(tempLongPathFilename);
try
{
var dateTime = Directory.GetLastWriteTime(tempLongPathFilename);
var fi = new DirectoryInfo(tempLongPathFilename);
Assert.AreEqual(fi.LastWriteTime, dateTime);
}
finally
{
Directory.Delete(tempLongPathFilename);
}
}
开发者ID:jerriclynsjohn,项目名称:LongPath,代码行数:15,代码来源:DirectoryTests.cs
示例7: TestGetFileSystemInfosWithSearch
public void TestGetFileSystemInfosWithSearch()
{
var di = new DirectoryInfo(uncDirectory);
var randomFileName = Path.GetRandomFileName();
var newDi = di.CreateSubdirectory(randomFileName);
try
{
var fi = new FileInfo(Path.Combine(newDi.FullName, "filename"));
using (fi.Create())
{
}
try
{
Assert.AreEqual(2, di.GetFileSystemInfos("*").Count());
}
finally
{
fi.Delete();
}
}
finally
{
newDi.Delete(true);
}
}
开发者ID:KsWare,项目名称:LongPath,代码行数:25,代码来源:UncDirectoryInfoTests.cs
示例8: TestGetFilesWithSearch
public void TestGetFilesWithSearch()
{
var di = new DirectoryInfo(uncDirectory);
var files = di.GetFiles("*").ToArray();
Assert.AreEqual(1, files.Length);
}
开发者ID:KsWare,项目名称:LongPath,代码行数:6,代码来源:UncDirectoryInfoTests.cs
示例9: TestGetDirectoriesWithSingleResultSubsetSearch
public void TestGetDirectoriesWithSingleResultSubsetSearch()
{
var randomFileName = "TestGetDirectoriesWithSubsetSearch";
var tempLongPathFilename = Path.Combine(uncDirectory, randomFileName);
Directory.CreateDirectory(tempLongPathFilename);
try
{
var di = new DirectoryInfo(uncDirectory);
var dirs = di.GetDirectories("A*").ToArray();
Assert.AreEqual(0, dirs.Length);
Assert.IsFalse(dirs.Any(f => f.Name == randomFileName));
}
finally
{
Directory.Delete(tempLongPathFilename);
}
}
开发者ID:KsWare,项目名称:LongPath,代码行数:17,代码来源:UncDirectoryInfoTests.cs
示例10: TestCreateSubdirectoryWithFileSecurity
public void TestCreateSubdirectoryWithFileSecurity()
{
var di = new DirectoryInfo(uncDirectory);
var randomFileName = Path.GetRandomFileName();
Pri.LongPath.DirectoryInfo newDi = null;
try
{
newDi = di.CreateSubdirectory(randomFileName, new DirectorySecurity());
Assert.IsNotNull(newDi);
Assert.IsTrue(di.Exists);
}
finally
{
if (newDi != null) newDi.Delete();
}
}
开发者ID:KsWare,项目名称:LongPath,代码行数:16,代码来源:UncDirectoryInfoTests.cs
示例11: TestToString
public void TestToString()
{
var fi = new DirectoryInfo(uncDirectory);
Assert.AreEqual(fi.DisplayPath, fi.ToString());
}
开发者ID:KsWare,项目名称:LongPath,代码行数:6,代码来源:UncDirectoryInfoTests.cs
示例12: TestSetLastWriteTimeUtcMissingFile
public void TestSetLastWriteTimeUtcMissingFile()
{
var filename = Path.Combine(uncDirectory, "gibberish.ext");
DateTime dateTime = DateTime.UtcNow.AddDays(1);
var di = new DirectoryInfo(filename);
di.LastWriteTimeUtc = dateTime;
}
开发者ID:KsWare,项目名称:LongPath,代码行数:7,代码来源:UncDirectoryInfoTests.cs
示例13: TestSetLastWriteTimeUtc
public void TestSetLastWriteTimeUtc()
{
var filename = Util.CreateNewFile(uncDirectory);
try
{
DateTime dateTime = DateTime.UtcNow.AddDays(1);
var di = new DirectoryInfo(filename);
di.LastWriteTimeUtc = dateTime;
Assert.AreEqual(dateTime, File.GetLastWriteTimeUtc(filename));
}
finally
{
File.Delete(filename);
}
}
开发者ID:KsWare,项目名称:LongPath,代码行数:15,代码来源:UncDirectoryInfoTests.cs
示例14: TestSetCreationTimeMissingFile
public void TestSetCreationTimeMissingFile()
{
var filename = Path.Combine(uncDirectory, "gibberish.ext");
DateTime dateTime = DateTime.Now.AddDays(1);
var di = new DirectoryInfo(filename);
di.CreationTime = dateTime;
}
开发者ID:KsWare,项目名称:LongPath,代码行数:7,代码来源:UncDirectoryInfoTests.cs
示例15: TestGetAccessControlSections
public void TestGetAccessControlSections()
{
var tempLongPathFilename = Path.Combine(uncDirectory, Path.GetRandomFileName());
Directory.CreateDirectory(tempLongPathFilename);
try
{
var di = new DirectoryInfo(tempLongPathFilename);
var security = di.GetAccessControl(AccessControlSections.Access);
Assert.IsNotNull(security);
Assert.AreEqual(typeof(FileSystemRights), security.AccessRightType);
Assert.AreEqual(typeof(FileSystemAccessRule), security.AccessRuleType);
Assert.AreEqual(typeof(FileSystemAuditRule), security.AuditRuleType);
Assert.IsTrue(security.AreAccessRulesCanonical);
Assert.IsTrue(security.AreAuditRulesCanonical);
Assert.IsFalse(security.AreAccessRulesProtected);
Assert.IsFalse(security.AreAuditRulesProtected);
var securityGetAccessRules = security.GetAuditRules(true, true, typeof(System.Security.Principal.NTAccount)).Cast<FileSystemAccessRule>();
Assert.AreEqual(0, securityGetAccessRules.Count());
AuthorizationRuleCollection perm = security.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
var ntAccount = new System.Security.Principal.NTAccount(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
FileSystemAccessRule rule = perm.Cast<FileSystemAccessRule>().SingleOrDefault(e => ntAccount == e.IdentityReference);
Assert.IsNotNull(rule);
Assert.IsTrue((rule.FileSystemRights & FileSystemRights.FullControl) != 0);
}
finally
{
Directory.Delete(tempLongPathFilename);
}
}
开发者ID:KsWare,项目名称:LongPath,代码行数:29,代码来源:UncDirectoryInfoTests.cs
示例16: TestGetDirectoriesWithAllSearch
public void TestGetDirectoriesWithAllSearch()
{
var randomFileName = Path.GetRandomFileName();
var tempLongPathFilename = Path.Combine(uncDirectory, randomFileName);
Directory.CreateDirectory(tempLongPathFilename);
try
{
var di = new DirectoryInfo(uncDirectory);
var dirs = di.GetDirectories("*").ToArray();
Assert.AreEqual(1, dirs.Length);
Assert.IsTrue(dirs.Any(f => f.Name == randomFileName));
}
finally
{
Directory.Delete(tempLongPathFilename);
}
}
开发者ID:KsWare,项目名称:LongPath,代码行数:17,代码来源:UncDirectoryInfoTests.cs
示例17: TestCreateWithFileSecurity
public void TestCreateWithFileSecurity()
{
var tempLongPathFilename = Path.Combine(uncDirectory, Path.GetRandomFileName());
var di = new DirectoryInfo(tempLongPathFilename);
try
{
di.Create(new DirectorySecurity());
Assert.IsTrue(Directory.Exists(tempLongPathFilename));
}
finally
{
di.Delete();
}
}
开发者ID:KsWare,项目名称:LongPath,代码行数:14,代码来源:UncDirectoryInfoTests.cs
示例18: TestGetFiles
public void TestGetFiles()
{
var di = new DirectoryInfo(uncDirectory);
var files = di.GetFiles().ToArray();
Assert.AreEqual(1, files.Length);
Assert.IsTrue(files.Any(f => f.Name == Filename));
}
开发者ID:KsWare,项目名称:LongPath,代码行数:7,代码来源:UncDirectoryInfoTests.cs
示例19: TestEnumerateDirectoriesWithSearchWithNoResults
public void TestEnumerateDirectoriesWithSearchWithNoResults()
{
var randomFileName = Path.GetRandomFileName();
var tempLongPathFilename = Path.Combine(uncDirectory, randomFileName);
Directory.CreateDirectory(tempLongPathFilename);
try
{
var di = new DirectoryInfo(uncDirectory);
var dirs = di.EnumerateDirectories("gibberish").ToArray();
Assert.AreEqual(0, dirs.Length);
}
finally
{
Directory.Delete(tempLongPathFilename);
}
}
开发者ID:KsWare,项目名称:LongPath,代码行数:16,代码来源:UncDirectoryInfoTests.cs
示例20: TestGetFilesWithSearchWithNoResults
public void TestGetFilesWithSearchWithNoResults()
{
var di = new DirectoryInfo(uncDirectory);
var files = di.GetFiles("giberish").ToArray();
Assert.AreEqual(0, files.Length);
}
开发者ID:KsWare,项目名称:LongPath,代码行数:6,代码来源:UncDirectoryInfoTests.cs
注:本文中的Pri.LongPath.DirectoryInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论