本文整理汇总了C#中SchwabenCode.QuickIO.QuickIOPathInfo类的典型用法代码示例。如果您正苦于以下问题:C# QuickIOPathInfo类的具体用法?C# QuickIOPathInfo怎么用?C# QuickIOPathInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QuickIOPathInfo类属于SchwabenCode.QuickIO命名空间,在下文中一共展示了QuickIOPathInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnumerateDirectoryMetadata
/// <summary>
/// Receives <see cref="QuickIODirectoryMetadata"/> of current directory
/// </summary>
/// <returns><see cref="QuickIODirectoryMetadata"/></returns>
public static QuickIODirectoryMetadata EnumerateDirectoryMetadata( QuickIOPathInfo pathInfo, QuickIOEnumerateOptions enumerateOptions = QuickIOEnumerateOptions.None )
{
Contract.Requires( pathInfo != null );
Contract.Ensures( Contract.Result<QuickIODirectoryMetadata>() != null );
return EnumerateDirectoryMetadata( pathInfo.FullNameUnc, enumerateOptions );
}
示例2: WriteAllBytes
/// <summary>
/// Writes the specified byte array.
/// If the file already exists, it is overwritten.
/// </summary>
/// <param name="pathInfo">The file. </param>
/// <param name="bytes">The bytes to write. </param>
/// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.writeallbytes(v=vs.110).aspx</remarks>
public static void WriteAllBytes( QuickIOPathInfo pathInfo, IEnumerable<byte> bytes )
{
Contract.Requires( pathInfo != null );
Contract.Requires( bytes != null );
WriteAllBytes( pathInfo.FullNameUnc, bytes.ToArray() );
}
示例3: OpenRead
/// <summary>
/// Opens an existing file for reading.
/// </summary>
/// <param name="pathInfo">The file to be opened for reading. </param>
/// <returns>A read-only <see cref="FileStream"/> on the specified path.</returns>
/// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.openread(v=vs.110).aspx</remarks>
public static FileStream OpenRead( QuickIOPathInfo pathInfo )
{
Contract.Requires( pathInfo != null );
Contract.Ensures( Contract.Result<StreamReader>() != null );
return OpenRead( pathInfo.FullNameUnc );
}
示例4: AppendAllLines
/// <summary>
/// Appends lines by using the specified encoding.
/// If the file does not exist, it creates the file.
/// </summary>
/// <param name="pathInfo">The file to append the lines to. The file is created if it doesn't exist.</param>
/// <param name="contents">The lines to append.</param>
/// <param name="encoding">The character encoding.</param>
/// <remarks>http://msdn.microsoft.com/en-us/library/dd383356(v=vs.110).aspx</remarks>
public static void AppendAllLines( QuickIOPathInfo pathInfo, IEnumerable<string> contents, Encoding encoding = null )
{
Contract.Requires( pathInfo != null );
Contract.Requires( contents != null );
AppendAllLines( pathInfo.FullNameUnc, contents, encoding );
}
示例5: Copy
/// <summary>
/// Copies a directory and all contents
/// </summary>
/// <param name="source">Source directory</param>
/// <param name="target">Target directory</param>
/// <param name="overwrite">true to overwrite existing files</param>
/// <param name="cancellationToken">Cancallation Token</param>
public static void Copy( QuickIODirectoryInfo source, QuickIOPathInfo target, bool overwrite = false, CancellationToken cancellationToken = default( CancellationToken ) )
{
Contract.Requires( source != null );
Contract.Requires( target != null );
throw new NotImplementedException();
}
示例6: AppendAllText
/// <summary>
/// Appends the specified string.
/// If the file does not exist, it creates the file.
/// </summary>
/// <param name="pathInfo">The file to append the specified string to.</param>
/// <param name="contents">The string to append to the file.</param>
/// <param name="encoding">The character encoding.</param>
/// <remarks>http://msdn.microsoft.com/en-us/library/ms143356(v=vs.110).aspx</remarks>
public static void AppendAllText( QuickIOPathInfo pathInfo, string contents, Encoding encoding )
{
Contract.Requires( pathInfo != null );
Contract.Requires( contents != null );
AppendAllText( pathInfo.FullNameUnc, contents, encoding );
}
示例7: 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." );
}
}
示例8: Copy
/// <summary>
/// Copies a directory and all contents
/// </summary>
/// <param name="source">Source directory</param>
/// <param name="target">Target directory</param>
/// <param name="overwrite">true to overwrite existing files</param>
public static void Copy( QuickIODirectoryInfo source, QuickIOPathInfo target, bool overwrite = false )
{
Invariant.NotNull( source );
Invariant.NotNull( target );
var allContentUncPaths = EnumerateFileSystemEntryPaths( source, QuickIOPatternConstants.All, SearchOption.AllDirectories, QuickIOPathType.UNC );
foreach ( var entry in allContentUncPaths )
{
string sourcePathUnc = entry.Key;
var targetFullnameUnc = target.FullNameUnc + sourcePathUnc.Substring( source.FullNameUnc.Length );
switch ( entry.Value )
{
case QuickIOFileSystemEntryType.Directory:
{
QuickIODirectory.Create( targetFullnameUnc, true );
}
break;
case QuickIOFileSystemEntryType.File:
{
QuickIOFile.Copy( sourcePathUnc, targetFullnameUnc, overwrite );
}
break;
}
}
}
示例9: CalculateHash
/// <summary>
/// File content hash calculation
/// </summary>
public static QuickIOHashResult CalculateHash( QuickIOPathInfo pathInfo, QuickIOHashImplementationType hashImplementationType )
{
Contract.Requires( pathInfo != null );
switch( hashImplementationType )
{
case QuickIOHashImplementationType.SHA1:
return CalculateSha1Hash( pathInfo );
case QuickIOHashImplementationType.SHA256:
return CalculateSha256Hash( pathInfo );
case QuickIOHashImplementationType.SHA384:
return CalculateSha384Hash( pathInfo );
case QuickIOHashImplementationType.SHA512:
return CalculateSha512Hash( pathInfo );
case QuickIOHashImplementationType.MD5:
return CalculateMD5Hash( pathInfo );
default:
throw new NotImplementedException( "Type " + hashImplementationType + " not implemented." );
}
}
示例10: Open
/// <summary>
/// Opens a <see cref="FileStream"/>
/// </summary>
/// <param name="pathInfo">The file to open. </param>
/// <param name="mode"><see cref="FileMode"/> </param>
/// <param name="access"><see cref="FileAccess"/></param>
/// <param name="share"><see cref="FileShare"/></param>
/// <returns><see cref="FileStream"/></returns>
/// <remarks>http://msdn.microsoft.com/en-us/library/y973b725(v=vs.110).aspx</remarks>
public static FileStream Open( QuickIOPathInfo pathInfo, FileMode mode, FileAccess access, FileShare share )
{
Contract.Requires( pathInfo != null );
Contract.Ensures( Contract.Result<FileStream>() != null );
return OpenFileStream( pathInfo.FullNameUnc, access, mode, share );
}
示例11: QuickIODirectoryInfo
/// <summary>
/// Creates the folder information on the basis of the path and the handles
/// </summary>
/// <param name="pathInfo"><see cref="QuickIOPathInfo"/></param>
/// <param name="win32FindData"><see cref="Win32FindData"/></param>
internal QuickIODirectoryInfo( QuickIOPathInfo pathInfo, Win32FindData win32FindData )
: base(pathInfo, win32FindData)
{
if ( win32FindData != null )
{
RetriveDateTimeInformation( win32FindData );
}
}
示例12: CalculateMD5Hash
/// <summary>
/// File content hash calculation using MD5
/// </summary>
/// <returns><see cref="QuickIOHashResult"/></returns>
/// <example>
/// <code>
/// // Show human readable hash
/// QuickIOHashResult hashResult = QuickIOFile.CalculateMD5Hash( "C:\temp\image.bin" );
/// Console.WriteLine("Hash: {0}", hashResult.Format( Encoding.UTF8, "x2" );
/// </code>
/// </example>
public static QuickIOHashResult CalculateMD5Hash( QuickIOPathInfo pathInfo )
{
using ( var fs = OpenRead( pathInfo ) )
using ( var hashAlgorithm = new MD5CryptoServiceProvider( ) )
{
return CalculateHash( hashAlgorithm, fs );
}
}
示例13: WriteAllBytes
/// <summary>
/// Writes the specified byte array.
/// If the file already exists, it is overwritten.
/// </summary>
/// <param name="pathInfo">The file. </param>
/// <param name="bytes">The bytes to write. </param>
/// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.writeallbytes(v=vs.110).aspx</remarks>
public static void WriteAllBytes( QuickIOPathInfo pathInfo, byte[ ] bytes )
{
using ( var fileStream = OpenFileStream( pathInfo, FileAccess.ReadWrite, FileMode.Create, FileShare.None ) )
{
fileStream.Seek( 0, SeekOrigin.Begin );
fileStream.Write( bytes, 0, bytes.Length );
}
}
示例14: QuickIOFileSystemEntryBase
/// <summary>
/// Initializes a new instance of the QuickIOAbstractBase class, which acts as a wrapper for a file path.
/// </summary>
/// <param name="pathInfo"><see cref="QuickIOPathInfo"/></param>
/// <param name="findData"><see cref="Win32FindData"/></param>
internal QuickIOFileSystemEntryBase( QuickIOPathInfo pathInfo, Win32FindData findData )
{
this.FindData = findData;
this.PathInfo = pathInfo;
if ( findData != null )
{
this.Attributes = findData.dwFileAttributes;
}
}
示例15: CalculateSha1Hash
/// <summary>
/// File content hash calculation using SHA1
/// </summary>
/// <returns><see cref="QuickIOHashResult"/></returns>
/// <example>
/// <code>
/// // Show human readable hash
/// QuickIOHashResult hashResult = QuickIOFile.CalculateSha1Hash( "C:\temp\image.bin" );
/// Console.WriteLine("Hash: {0}", hashResult.Format( Encoding.UTF8, "x2" );
/// </code>
/// </example>
public static QuickIOHashResult CalculateSha1Hash( QuickIOPathInfo pathInfo )
{
Contract.Requires( pathInfo != null );
using( var fs = OpenRead( pathInfo ) )
using( var hashAlgorithm = new SHA1Managed() )
{
return CalculateHash( hashAlgorithm, fs );
}
}