本文整理汇总了C#中QuickIOPathInfo类的典型用法代码示例。如果您正苦于以下问题:C# QuickIOPathInfo类的具体用法?C# QuickIOPathInfo怎么用?C# QuickIOPathInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QuickIOPathInfo类属于命名空间,在下文中一共展示了QuickIOPathInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateDirectory
/// <summary>
/// Creates a new directory. If <paramref name="recursive"/> is false, the parent directory must exists.
/// </summary>
/// <param name="pathInfo"><see cref="QuickIOPathInfo"/></param>
/// <param name="recursive">If <paramref name="recursive"/> is false, the parent directory must exist.</param>
/// <exception cref="PathAlreadyExistsException">The specified path already exists.</exception>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
public static void CreateDirectory( QuickIOPathInfo pathInfo, bool recursive = false )
{
if ( recursive )
{
var parent = pathInfo.Parent;
if ( parent.IsRoot )
{
// Root
if ( !parent.Exists )
{
throw new PathNotFoundException( "Root path does not exists. You cannot create a root this way.", parent.FullName );
}
}
else if ( !parent.Exists )
{
CreateDirectory( parent, recursive );
}
}
if ( pathInfo.CheckExistance( QuickIOFileSystemEntryType.Directory ) )
{
return;
}
var created = Win32SafeNativeMethods.CreateDirectory( pathInfo.FullNameUnc, IntPtr.Zero );
var win32Error = Marshal.GetLastWin32Error( );
if ( !created )
{
InternalQuickIOCommon.NativeExceptionMapping( pathInfo.FullName, win32Error );
}
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:39,代码来源:InternalQuickIO.cs
示例2: Exists
/// <summary>
/// Checks whether the path with the expected system entry type exists
/// </summary>
/// <param name="pathInfo">A file or a directory</param>
/// <param name="systemEntryType"><see cref="QuickIOFileSystemEntryType"/> you are searching for</param>
/// <returns></returns>
/// <exception cref="UnmatchedFileSystemEntryTypeException">Path exists but it's not the type you're searching for.</exception>
public static Boolean Exists( QuickIOPathInfo pathInfo, QuickIOFileSystemEntryType systemEntryType )
{
switch ( systemEntryType )
{
case QuickIOFileSystemEntryType.Directory:
try
{
InternalQuickIO.LoadDirectoryFromPathInfo( pathInfo );
return true;
}
catch ( PathNotFoundException )
{
return false;
}
case QuickIOFileSystemEntryType.File:
try
{
InternalQuickIO.LoadFileFromPathInfo( pathInfo );
return true;
}
catch ( PathNotFoundException )
{
return false;
}
default:
throw new ArgumentException( "Unknown QuickIOFileSystemEntryType passed." );
}
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:37,代码来源:InternalQuickIOCommon.cs
示例3: CreateSafeFileHandle
/// <summary>
/// Returns the <see cref="SafeFileHandle"/> and fills <see cref="Win32FindData"/> from the passes path.
/// </summary>
/// <param name="pathInfo">Path to the file system entry</param>
/// <returns><see cref="SafeFileHandle"/></returns>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
internal static SafeFileHandle CreateSafeFileHandle( QuickIOPathInfo pathInfo )
{
Contract.Requires( pathInfo != null );
Contract.Ensures( Contract.Result<SafeFileHandle>() != null );
return CreateSafeFileHandle( pathInfo.FullNameUnc );
}
开发者ID:Invisibility,项目名称:QuickIO,代码行数:14,代码来源:InternalQuickIO.FileHandle.cs
示例4: AddAttribute
/// <summary>
/// Adds a file attribute
/// </summary>
/// <param name="pathInfo">Affected target</param>
/// <param name="attribute">Attribute to add</param>
/// <returns>true if added. false if already exists in attributes</returns>
public static Boolean AddAttribute( QuickIOPathInfo pathInfo, FileAttributes attribute )
{
if ( ( pathInfo.Attributes & attribute ) != attribute )
{
var attributes = pathInfo.Attributes;
attributes |= attribute;
SetAttributes( pathInfo, attributes );
return true;
}
return false;
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:18,代码来源:InternalQuickIO.cs
示例5: Exists
/// <summary>
/// Checks whether the path with the expected system entry type exists
/// </summary>
/// <param name="path">Path to a file or a directory</param>
/// <param name="systemEntryType"><see cref="QuickIOFileSystemEntryType"/> you are searching for</param>
/// <returns></returns>
/// <exception cref="UnmatchedFileSystemEntryTypeException">Path exists but it's not the type you're searching for.</exception>
public static Boolean Exists( String path, QuickIOFileSystemEntryType systemEntryType )
{
var info = new QuickIOPathInfo( path );
if ( !info.Exists )
{
return false;
}
if ( info.IsRoot && systemEntryType == QuickIOFileSystemEntryType.Directory ) // root is always directory
{
return true;
}
if ( info.SystemEntryType == systemEntryType )
{
return true;
}
throw new UnmatchedFileSystemEntryTypeException( systemEntryType, info.SystemEntryType, info.FullName );
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:27,代码来源:InternalQuickIOCommon.cs
示例6: QuickIOPathInfoFile
public void QuickIOPathInfoFile()
{
string parent = QuickIOPath.Combine( CurrentPath(), "_TestFiles" );
string fullpath = QuickIOPath.Combine( CurrentPath(), "_TestFiles", "ExistingTestFile.txt" );
string fullPathUnc = QuickIOPath.ToPathUnc( fullpath );
string root = QuickIOPath.GetPathRoot( fullpath );
QuickIOPathInfo pi = new QuickIOPathInfo( fullpath );
pi.Should().NotBe( null );
pi.Name.Should().Be( "ExistingTestFile.txt" );
pi.FullName.Should().Be( fullpath );
pi.FullNameUnc.Should().Be( fullPathUnc );
pi.Parent.Should().Be( parent );
pi.Root.Should().Be( root );
pi.IsRoot.Should().Be( false );
pi.FindData.Should().NotBe( null );
InternalHelpers.ContainsFileAttribute( pi.Attributes, FileAttributes.Directory ).Should().Be( false );
pi.Exists.Should().Be( true );
pi.SystemEntryType.Should().Be( QuickIOFileSystemEntryType.File );
}
开发者ID:Invisibility,项目名称:QuickIO,代码行数:24,代码来源:QuickIOPathInfoTests.cs
示例7: EnumerateFileSystemEntryPaths
/// <summary>
/// Determined all sub file system entries of a directory
/// </summary>
/// <param name="pathInfo">Path of the directory</param>
/// <param name="pattern">Search pattern. Uses Win32 native filtering.</param>
/// <param name="searchOption"><see cref="SearchOption"/></param>
/// <param name="pathFormatReturn">Specifies the type of path to return.</param>
/// <param name="enumerateOptions">The enumeration options for exception handling</param>
/// <returns>Collection of <see cref="QuickIODirectoryInfo"/></returns>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
internal static IEnumerable<KeyValuePair<String, QuickIOFileSystemEntryType>> EnumerateFileSystemEntryPaths( QuickIOPathInfo pathInfo, String pattern = QuickIOPatternConstants.All, SearchOption searchOption = SearchOption.TopDirectoryOnly, QuickIOEnumerateOptions enumerateOptions = QuickIOEnumerateOptions.None, QuickIOPathType pathFormatReturn = QuickIOPathType.Regular )
{
return EnumerateFileSystemEntryPaths( pathInfo.FullNameUnc, pattern, searchOption, enumerateOptions, pathFormatReturn );
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:14,代码来源:InternalQuickIO.cs
示例8: EnumerateDirectoryMetadata
/// <summary>
/// Determined metadata of directory
/// </summary>
/// <param name="pathInfo">Path of the directory</param>
/// <param name="enumerateOptions">The enumeration options for exception handling</param>
/// <returns><see cref="QuickIODirectoryMetadata"/> started with the given directory</returns>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
internal static QuickIODirectoryMetadata EnumerateDirectoryMetadata( QuickIOPathInfo pathInfo, QuickIOEnumerateOptions enumerateOptions = QuickIOEnumerateOptions.None )
{
return EnumerateDirectoryMetadata( pathInfo.FullNameUnc, pathInfo.FindData, enumerateOptions );
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:11,代码来源:InternalQuickIO.cs
示例9: CreateSafeFileHandle
/// <summary>
/// Returns the <see cref="SafeFileHandle"/> and fills <see cref="Win32FindData"/> from the passes path.
/// </summary>
/// <param name="info">Path to the file system entry</param>
/// <returns><see cref="SafeFileHandle"/></returns>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
internal static SafeFileHandle CreateSafeFileHandle( QuickIOPathInfo info )
{
return CreateSafeFileHandle( info.FullNameUnc );
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:10,代码来源:InternalQuickIO.cs
示例10: SetLastWriteTimeUtc
/// <summary>
/// Sets the time at which the file or directory was last written to (UTC)
/// </summary>
/// <param name="pathInfo">Affected file or directory</param>
/// <param name="utcTime">The time that is to be used (UTC)</param>
public static void SetLastWriteTimeUtc( QuickIOPathInfo pathInfo, DateTime utcTime )
{
var longTime = utcTime.ToFileTime( );
using ( var fileHandle = OpenReadWriteFileSystemEntryHandle( pathInfo.FullNameUnc ) )
{
if ( !Win32SafeNativeMethods.SetLastWriteFileTime( fileHandle, IntPtr.Zero, IntPtr.Zero, ref longTime ) )
{
var win32Error = Marshal.GetLastWin32Error( );
InternalQuickIOCommon.NativeExceptionMapping( pathInfo.FullName, win32Error );
}
}
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:17,代码来源:InternalQuickIO.cs
示例11: SetAllFileTimes
/// <summary>
/// Sets the dates and times of given directory or file.
/// </summary>
/// <param name="pathInfo">Affected file or directory</param>
/// <param name="creationTimeUtc">The time that is to be used (UTC)</param>
/// <param name="lastAccessTimeUtc">The time that is to be used (UTC)</param>
/// <param name="lastWriteTimeUtc">The time that is to be used (UTC)</param>
public static void SetAllFileTimes( QuickIOPathInfo pathInfo, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc )
{
var longCreateTime = creationTimeUtc.ToFileTime( );
var longAccessTime = lastAccessTimeUtc.ToFileTime( );
var longWriteTime = lastWriteTimeUtc.ToFileTime( );
using ( var fileHandle = OpenReadWriteFileSystemEntryHandle( pathInfo.FullNameUnc ) )
{
if ( Win32SafeNativeMethods.SetAllFileTimes( fileHandle, ref longCreateTime, ref longAccessTime, ref longWriteTime ) == 0 )
{
var win32Error = Marshal.GetLastWin32Error( );
InternalQuickIOCommon.NativeExceptionMapping( pathInfo.FullName, win32Error );
}
}
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:22,代码来源:InternalQuickIO.cs
示例12: EnumerateFileSystemEntryPaths
/// <summary>
/// Determined all sub file system entries of a directory
/// </summary>
/// <param name="pathInfo">Path of the directory</param>
/// <param name="searchOption"><see cref="SearchOption"/></param>
/// <param name="pathFormatReturn">Specifies the type of path to return.</param>
/// <param name="enumerateOptions">The enumeration options for exception handling</param>
/// <returns>Collection of <see cref="QuickIODirectoryInfo"/></returns>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
internal static IEnumerable<KeyValuePair<String, QuickIOFileSystemEntryType>> EnumerateFileSystemEntryPaths( QuickIOPathInfo pathInfo, SearchOption searchOption, QuickIOEnumerateOptions enumerateOptions, QuickIOPathType pathFormatReturn = QuickIOPathType.Regular )
{
return EnumerateFileSystemEntryPaths( pathInfo.FullNameUnc, searchOption, enumerateOptions, pathFormatReturn );
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:13,代码来源:InternalQuickIO.cs
示例13: EnumerateFileSystemEntries
/// <summary>
/// Determined all sub system entries of a directory
/// </summary>
/// <param name="pathInfo">Path of the directory</param>
/// <param name="searchOption"><see cref="SearchOption"/></param>
/// <param name="enumerateOptions">The enumeration options for exception handling</param>
/// <returns>Collection of <see cref="QuickIODirectoryInfo"/></returns>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
internal static IEnumerable<KeyValuePair<QuickIOPathInfo, QuickIOFileSystemEntryType>> EnumerateFileSystemEntries( QuickIOPathInfo pathInfo, SearchOption searchOption, QuickIOEnumerateOptions enumerateOptions )
{
return EnumerateFileSystemEntries( pathInfo.FullNameUnc, searchOption, enumerateOptions );
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:12,代码来源:InternalQuickIO.cs
示例14: EnumerateFiles
/// <summary>
/// Determined all files of a directory
/// </summary>
/// <param name="pathInfo">Path of the directory</param>
/// <param name="searchOption"><see cref="SearchOption"/></param>
/// <returns>Collection of files</returns>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
internal static IEnumerable<QuickIOFileInfo> EnumerateFiles( QuickIOPathInfo pathInfo, SearchOption searchOption, QuickIOEnumerateOptions enumerateOptions )
{
return EnumerateFiles( pathInfo.FullNameUnc, searchOption, enumerateOptions );
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:11,代码来源:InternalQuickIO.cs
示例15: Exists
/// <summary>
/// Reurns true if passed path exists
/// </summary>
/// <param name="pathInfo">Path to check</param>
public static Boolean Exists( QuickIOPathInfo pathInfo )
{
var win32FindData = new Win32FindData( );
int win32Error;
var path = pathInfo.FullNameUnc;
if ( pathInfo.IsRoot )
{
path = QuickIOPath.Combine( path, "*" );
}
using ( var fileHandle = FindFirstSafeFileHandle( path, win32FindData, out win32Error ) )
{
// Take care of invalid handles
return !fileHandle.IsInvalid;
}
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:21,代码来源:InternalQuickIO.cs
示例16: GetFindDataFromPath
///// <summary>
///// Returns the <see cref="Win32FindData"/> from specified <paramref name="fullUncPath"/>
///// </summary>
///// <param name="fullUncPath">Path to the file system entry</param>
///// <returns><see cref="Win32FindData"/></returns>
///// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
///
/// <summary>
/// Returns the <see cref="Win32FindData"/> from specified <paramref name="pathInfo"/>
/// </summary>
/// <param name="pathInfo">Path to the file system entry</param>
/// <returns><see cref="Win32FindData"/></returns>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
public static Win32FindData GetFindDataFromPath( QuickIOPathInfo pathInfo )
{
var win32FindData = new Win32FindData( );
int win32Error;
using ( var fileHandle = FindFirstSafeFileHandle( pathInfo.FullNameUnc, win32FindData, out win32Error ) )
{
// Take care of invalid handles
if ( fileHandle.IsInvalid )
{
InternalQuickIOCommon.NativeExceptionMapping( pathInfo.FullName, win32Error );
}
// Treffer auswerten
// Ignore . and .. directories
if ( !InternalRawDataHelpers.IsSystemDirectoryEntry( win32FindData ) )
{
return win32FindData;
}
}
throw new PathNotFoundException( pathInfo.FullName );
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:35,代码来源:InternalQuickIO.cs
示例17: GetAttributes
/// <summary>
/// Gets the <see cref="FileAttributes"/> of the file on the entry.
/// </summary>
/// <param name="pathInfo">The path to the entry. </param>
/// <returns>The <see cref="FileAttributes"/> of the file on the entry.</returns>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
internal static FileAttributes GetAttributes( QuickIOPathInfo pathInfo )
{
return pathInfo.Attributes;
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:10,代码来源:InternalQuickIO.cs
示例18: LoadFileFromPathInfo
/// <summary>
/// Loads a file from specified path
/// </summary>
/// <param name="pathInfo">Full path</param>
/// <returns><see cref="QuickIOFileInfo"/></returns>
/// <exception cref="UnmatchedFileSystemEntryTypeException">Path exists but it's not a file; it's a directory.</exception>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
public static QuickIOFileInfo LoadFileFromPathInfo( QuickIOPathInfo pathInfo )
{
// Find First file
Win32FindData findData;
if ( TryGetFindDataFromPath( pathInfo, out findData ) )
{
// Entry found, check for file
if ( InternalQuickIOCommon.DetermineFileSystemEntry( findData ) == QuickIOFileSystemEntryType.File )
{
return new QuickIOFileInfo( pathInfo, findData );
}
throw new UnmatchedFileSystemEntryTypeException( QuickIOFileSystemEntryType.File, QuickIOFileSystemEntryType.Directory, pathInfo.FullName );
}
// Nothing found
throw new PathNotFoundException( pathInfo.FullName );
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:24,代码来源:InternalQuickIO.cs
示例19: CreateFile
/// <summary>
/// Creates a new file.
/// </summary>
/// <exception cref="PathAlreadyExistsException">The specified path already exists.</exception>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
public static void CreateFile( QuickIOPathInfo pathInfo, FileAccess fileAccess = FileAccess.Write, FileShare fileShare = FileShare.None, FileMode fileMode = FileMode.Create, FileAttributes fileAttributes = 0 )
{
using ( var fileHandle = Win32SafeNativeMethods.CreateFile( pathInfo.FullNameUnc, fileAccess, fileShare, IntPtr.Zero, fileMode, fileAttributes, IntPtr.Zero ) )
{
var win32Error = Marshal.GetLastWin32Error( );
if ( fileHandle.IsInvalid )
{
InternalQuickIOCommon.NativeExceptionMapping( pathInfo.FullName, win32Error );
}
}
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:16,代码来源:InternalQuickIO.cs
示例20: SetAttributes
/// <summary>
/// Sets the specified <see cref="FileAttributes"/> of the entry on the specified path.
/// </summary>
/// <param name="pathInfo">The path to the entry.</param>
/// <param name="attributes">A bitwise combination of the enumeration values.</param>
/// <exception cref="Win32Exception">Unmatched Exception</exception>
/// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
public static void SetAttributes( QuickIOPathInfo pathInfo, FileAttributes attributes )
{
if ( !Win32SafeNativeMethods.SetFileAttributes( pathInfo.FullNameUnc, ( uint ) attributes ) )
{
var win32Error = Marshal.GetLastWin32Error( );
InternalQuickIOCommon.NativeExceptionMapping( pathInfo.FullName, win32Error );
}
}
开发者ID:Kudach,项目名称:QuickIO,代码行数:15,代码来源:InternalQuickIO.cs
注:本文中的QuickIOPathInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论