本文整理汇总了C#中System.IO.FileSystemInfo类的典型用法代码示例。如果您正苦于以下问题:C# FileSystemInfo类的具体用法?C# FileSystemInfo怎么用?C# FileSystemInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileSystemInfo类属于System.IO命名空间,在下文中一共展示了FileSystemInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MarkdownTreeNode
public MarkdownTreeNode(FileSystemInfo location, string relativePathFromRoot, XElement markdownContent)
{
this.OriginalLocation = location;
this.OriginalLocationUrl = location.ToUri();
this.RelativePathFromRoot = relativePathFromRoot;
this.MarkdownContent = markdownContent;
}
示例2: ToStringArray
private static string[] ToStringArray(FileSystemInfo obj,
IEnumerable<object> paths)
{
if (null == obj)
{
throw new ArgumentNullException("obj");
}
var args = new List<string>
{
obj.FullName
};
#if NET20
if (ObjectExtensionMethods.IsNotNull(paths))
#else
if (paths.IsNotNull())
#endif
{
var range = paths
#if NET20
.Where(x => ObjectExtensionMethods.IsNotNull(x))
#else
.Where(x => x.IsNotNull())
#endif
.Select(path => path.ToString().RemoveIllegalFileCharacters());
args.AddRange(range);
}
return args.ToArray();
}
示例3: Format
public static void Format(FtpCommandContext context, FileSystemInfo fileInfo, StringBuilder output)
{
var isFile = fileInfo is FileInfo;
//Size
output.AppendFormat("size={0};", isFile ? ((FileInfo)fileInfo).Length : 0);
//Permission
output.AppendFormat("perm={0}{1};",
/* Can read */ isFile ? "r" : "el",
/* Can write */ isFile ? "adfw" : "fpcm");
//Type
output.AppendFormat("type={0};", isFile ? "file" : "dir");
//Create
output.AppendFormat("create={0};", FtpDateUtils.FormatFtpDate(fileInfo.CreationTimeUtc));
//Modify
output.AppendFormat("modify={0};", FtpDateUtils.FormatFtpDate(fileInfo.LastWriteTimeUtc));
//File name
output.Append(DELIM);
output.Append(fileInfo.Name);
output.Append(NEWLINE);
}
示例4: ConvertFileSystemInfoToHleIoDirent
public static unsafe HleIoDirent ConvertFileSystemInfoToHleIoDirent(FileSystemInfo FileSystemInfo)
{
var HleIoDirent = default(HleIoDirent);
var FileInfo = (FileSystemInfo as FileInfo);
var DirectoryInfo = (FileSystemInfo as DirectoryInfo);
{
if (DirectoryInfo != null)
{
HleIoDirent.Stat.Size = 0;
HleIoDirent.Stat.Mode = SceMode.Directory | (SceMode)Convert.ToInt32("777", 8);
HleIoDirent.Stat.Attributes = IOFileModes.Directory;
PointerUtils.StoreStringOnPtr(FileSystemInfo.Name, Encoding.UTF8, HleIoDirent.Name);
}
else
{
HleIoDirent.Stat.Size = FileInfo.Length;
HleIoDirent.Stat.Mode = SceMode.File | (SceMode)Convert.ToInt32("777", 8);
//HleIoDirent.Stat.Attributes = IOFileModes.File | IOFileModes.CanRead | IOFileModes.CanWrite | IOFileModes.CanExecute;
HleIoDirent.Stat.Attributes = IOFileModes.File;
PointerUtils.StoreStringOnPtr(FileSystemInfo.Name.ToUpper(), Encoding.UTF8, HleIoDirent.Name);
}
HleIoDirent.Stat.DeviceDependentData0 = 10;
}
return HleIoDirent;
}
示例5: BuildFileBundleName
/// <summary>
/// 编译文件AssetBundle名字
/// </summary>
/// <param name="file">文件信息</param>
/// <param name="basePath">基础路径</param>
protected static void BuildFileBundleName(FileSystemInfo file , string basePath)
{
string extension = file.Extension;
string fullName = file.FullName.Standard();
string fileName = file.Name;
string baseFileName = fileName.Substring(0 , fileName.Length - extension.Length);
string assetName = fullName.Substring(basePath.Length);
assetName = assetName.Substring(0 , assetName.Length - fileName.Length).TrimEnd('/');
if(baseFileName + extension == ".DS_Store"){ return; }
int variantIndex = baseFileName.LastIndexOf(".");
string variantName = string.Empty;
if(variantIndex > 0){
variantName = baseFileName.Substring(variantIndex + 1);
}
AssetImporter assetImporter = AssetImporter.GetAtPath("Assets" + Env.ResourcesBuildPath + assetName + "/" + baseFileName + extension);
assetImporter.assetBundleName = assetName.TrimStart('/');
if(variantName != string.Empty){
assetImporter.assetBundleVariant = variantName;
}
}
示例6: CheckOut
public override string CheckOut(IPackageTree packageTree, FileSystemInfo destination)
{
SvnUpdateResult result = null;
using (var client = new SvnClient())
{
try
{
var svnOptions = new SvnCheckOutArgs();
if (UseRevision.HasValue)
svnOptions.Revision = new SvnRevision(UseRevision.Value);
client.CheckOut(new SvnUriTarget(new Uri(Url)), destination.FullName, svnOptions, out result);
}
catch (SvnRepositoryIOException sre)
{
HandleExceptions(sre);
}
catch (SvnObstructedUpdateException sue)
{
HandleExceptions(sue);
}
}
return result.Revision.ToString();
}
示例7: Item
public Item(FileSystemInfo info)
{
Id = Guid.NewGuid().ToString();
Name = info.Name;
Created = info.CreationTime;
Modified = info.LastWriteTime;
LastAccess = info.LastAccessTime;
var fileInfo = info as FileInfo;
if (fileInfo != null)
{
m_isReadOnly = fileInfo.IsReadOnly;
Size = fileInfo.Length;
IsFile = true;
}
else
{
IsFile = false;
}
FileSecurity fs = File.GetAccessControl(info.FullName);
var sidOwning = fs.GetOwner(typeof(SecurityIdentifier));
var ntAccount = sidOwning.Translate(typeof(NTAccount));
Owner = ntAccount.Value;
// todo: it's not so important, but still put here something like read, write etc.
var sidRules = fs.GetAccessRules(true, true, typeof(SecurityIdentifier));
List<string> rulesList = new List<string>(sidRules.Count);
for (int i = 0; i < sidRules.Count; i++)
{
rulesList.Add(sidRules[i].IdentityReference.Value);
}
Rights = string.Join("; ", rulesList);
}
示例8: Create
public IDirectoryTreeNode Create(FileSystemInfo root, FileSystemInfo location)
{
string relativePathFromRoot = root == null ? @".\" : PathExtensions.MakeRelativePath(root, location);
var directory = location as DirectoryInfo;
if (directory != null)
{
return new FolderDirectoryTreeNode(directory, relativePathFromRoot);
}
var file = location as FileInfo;
if (relevantFileDetector.IsFeatureFile(file))
{
Feature feature = featureParser.Parse(file.FullName);
if (feature != null)
{
return new FeatureDirectoryTreeNode(file, relativePathFromRoot, feature);
}
throw new InvalidOperationException("This feature file could not be read and will be excluded");
}
else if (relevantFileDetector.IsMarkdownFile(file))
{
XElement markdownContent = htmlMarkdownFormatter.Format(File.ReadAllText(file.FullName));
return new MarkdownTreeNode(file, relativePathFromRoot, markdownContent);
}
throw new InvalidOperationException("Cannot create an IItemNode-derived object for " + file.FullName);
}
示例9: CreateItemGetResponse
protected override Task<HttpResponseMessage> CreateItemGetResponse(FileSystemInfo info, string localFilePath)
{
// We don't support getting a file from the zip controller
// Conceivably, it could be a zip file containing just the one file, but that's rarely interesting
HttpResponseMessage notFoundResponse = Request.CreateResponse(HttpStatusCode.NotFound);
return Task.FromResult(notFoundResponse);
}
示例10: Restore
/// <summary>
/// This function launch the restore process, with the NpgsqlConnection parameters. Restore
/// will be done on the server and database pointed by the NpgsqlConnection
/// </summary>
/// <param name="connection">The NpgsqlConnection containg the database location
/// settings</param>
/// <param name="login">The login used to restore database</param>
/// <param name="password">The password associed to login</param>
/// <param name="backupFile">The backup file to restore</param>
/// <returns>Returns a Result that tells if operation succeeds</returns>
public Result Restore(
IDbConnection connection,
string login,
string password,
FileSystemInfo backupFile)
{
IPAddress connectionIpAddress = IPAddress.None;
if (connection != null)
{
// TODO fix connection.Host and connection.Port
if (IPAddress.TryParse(/*connection.Host*/ "127.0.0.1", out connectionIpAddress)
&& (connectionIpAddress != IPAddress.None))
{
return this.Restore(
connectionIpAddress,
5432, // (short)connection.Port,
connection.Database,
login,
password,
backupFile);
}
else
{
return Result.InvalidIpAddress;
}
}
return Result.InvalidNpgsqlConnection;
}
示例11: DoTouch
private static void DoTouch(FileSystemInfo fileSystemInfo, DateTime now)
{
FileAttributes fileAttributes = fileSystemInfo.Attributes;
try
{
fileSystemInfo.Attributes = FileAttributes.Normal;
fileSystemInfo.CreationTime = now;
fileSystemInfo.LastWriteTime = now;
fileSystemInfo.LastAccessTime = now;
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
//Restore Attributes in case anything happens
try
{
fileSystemInfo.Attributes = fileAttributes;
}
finally
{
}
}
}
示例12: VideoIsLocatedInAMovieFolder
internal static bool VideoIsLocatedInAMovieFolder(FileSystemInfo file)
{
Application.DoEvents();
bool isFilm = false;
foreach (string filmsFolder
in Settings.FilmsFolders)
{
if (String.IsNullOrEmpty
(filmsFolder))
continue;
if (!file.FullName
.Contains
(filmsFolder))
continue;
Debugger.LogMessageToFile(
"This video file is contained" +
" in the specified films root directory" +
" and will be considered to be a film.");
isFilm = true;
}
Application.DoEvents();
return isFilm;
}
示例13: GetFilesToZip
/// <summary>
/// Iterate thru all the filesysteminfo objects and add it to our zip file
/// </summary>
/// <param name="fileSystemInfosToZip">a collection of files/directores</param>
/// <param name="z">our existing ZipFile object</param>
private static void GetFilesToZip(FileSystemInfo[] fileSystemInfosToZip, ZipFile z)
{
//check whether the objects are null
if (fileSystemInfosToZip != null && z != null)
{
//iterate thru all the filesystem info objects
foreach (FileSystemInfo fi in fileSystemInfosToZip)
{
//check if it is a directory
if (fi is DirectoryInfo)
{
DirectoryInfo di = (DirectoryInfo)fi;
//add the directory
z.AddDirectory(di.FullName);
//drill thru the directory to get all
//the files and folders inside it.
GetFilesToZip(di.GetFileSystemInfos(), z);
}
else
{
//add it
z.Add(fi.FullName);
}
}
}
}
示例14: Add
/// <summary>
/// Add a File/Directory to the ZipFile
/// </summary>
/// <param name="z">ZipFile object</param>
/// <param name="fileSystemInfoToZip">the FileSystemInfo object to zip</param>
public static void Add(this ZipFile z, FileSystemInfo fileSystemInfoToZip)
{
Add(z, new FileSystemInfo[]
{
fileSystemInfoToZip
});
}
示例15: FileGroupInfo
public FileGroupInfo(FileSystemInfo _main, FileGroupInfoType _type)
{
main = _main;
type = _type;
files = new List<FileSystemInfo>();
numbers = new Dictionary<FileSystemInfo, uint>();
}