本文整理汇总了C#中System.IO.FileInfo.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.GetHashCode方法的具体用法?C# FileInfo.GetHashCode怎么用?C# FileInfo.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.GetHashCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
#region file hashcode
var fpath = @"D:\sysbacke450.GHO";
var file = new FileInfo(fpath);
var hash = file.GetHashCode();
var MD5Hash = HashHelper.ComputeMD5(fpath);
var copyPath = @"D:\sysbacke4501123123.GHO";
file.CopyTo(copyPath);
var fileC = new FileInfo(copyPath);
var hashCopy = fileC.GetHashCode();
var MD5HashC = HashHelper.ComputeMD5(copyPath);
Console.WriteLine(hash);
Console.WriteLine(MD5Hash);
Console.WriteLine(hashCopy);
Console.WriteLine(MD5HashC);
Console.ReadLine();
#endregion
#region webapi owin self host
//const string url = "http://localhost:8080/";
//var startOpts = new StartOptions(url)
//{
//};
////using (WebApp.Start<Startup>(startOpts))
////{
//// Console.WriteLine("Server run at " + url + " , press Enter to exit.");
//// Console.ReadLine();
////}
//using (WebApp.Start<Startup>(url: url))
//{
// var client = new HttpClient();
// var response = client.GetAsync(url + "api/HomeApi/1").Result;
// Console.WriteLine(response);
// Console.WriteLine(response.Content.ReadAsStringAsync().Result);
// Console.ReadLine();
//}
#endregion
}
示例2: Main
static void Main(string[] args)
{
//FileInfo
//DirectoryInfo
FileInfo file = new FileInfo(@"C:\testfolder\inf1.txt");
FileInfo file2 = new FileInfo(@"C:\testfolder\inf2.txt");
// Console.WriteLine("File name " + file.Name + ", File fullname " + file.FullName);
// Identical (^ is cout, v is printf())
if (file.Exists)
{
Console.WriteLine("File name {0}, File fullname {1}", file.Name, file.FullName);
Console.WriteLine(file.GetHashCode());
Console.WriteLine(file2.GetHashCode());
}
else
{
Console.WriteLine("There is no such file");
}
Console.ReadKey();
}
示例3: RealFile
public RealFile(FileInfo file)
{
_file = file;
ID = _file.GetHashCode();
}
示例4: CompileSourceFile
/// <summary>
/// Compiles the source file.
/// </summary>
/// <param name="sourceFile">The source file.</param>
/// <param name="source">The source.</param>
/// <returns>Compiler results.</returns>
private static CompilerResults CompileSourceFile(FileInfo sourceFile, string source)
{
CompilerResults results = null;
string extension = sourceFile.Extension.TrimStart('.').ToUpperInvariant();
switch (extension)
{
case "CS":
results = CSharpTestFile.Compile(source, sourceFile.GetHashCode().ToString());
break;
case "VB":
results = VBTestFile.Compile(source, sourceFile.GetHashCode().ToString());
break;
}
return results;
}
示例5: StartDoMagic
private void StartDoMagic(FileInfo targetFileInfo, string targetDirectoryPath, string destinationDirectoryPath)
{
try
{
if (targetFileInfo == null)
throw new ArgumentNullException("targetFileInfo");
if (destinationDirectoryPath == null)
throw new ArgumentNullException("destinationDirectoryPath");
var hash = targetFileInfo.GetHashCode();
var tempFileName = Path.Combine(PathMap.CachePath, hash + ".bin");
if (File.Exists(tempFileName))
File.Delete(tempFileName);
File.WriteAllBytes(tempFileName, new byte[]
{
51
});
var arguments = string.Format("--create --ips \"{0}\" \"{1}\"",
Path.Combine(PathMap.ExecutablePath, tempFileName), targetFileInfo.FullName);
var process = new Process
{
StartInfo =
{
FileName = "flips.exe",
Arguments = arguments,
UseShellExecute = false
}
};
process.Start();
process.WaitForExit();
var output = targetFileInfo.DirectoryName.Replace(targetDirectoryPath + "\\", "")
.Replace(targetDirectoryPath, "");
var destinationFullDirectoryPath = Path.Combine(destinationDirectoryPath, output);
if (!Directory.Exists(destinationFullDirectoryPath))
Directory.CreateDirectory(destinationFullDirectoryPath);
var ipsFileName = Path.GetFileNameWithoutExtension(targetFileInfo.FullName) + ".ips";
var ipsFilePath = Path.Combine(targetFileInfo.DirectoryName, ipsFileName);
var destinationFullFilePath = Path.Combine(destinationFullDirectoryPath, ipsFileName);
if (File.Exists(destinationFullFilePath))
File.Delete(destinationFullFilePath);
File.Move(ipsFilePath, destinationFullFilePath);
}
catch (Exception e)
{
_exceptions.Add(e);
if (_exceptions.Count < MaxExceptionsCount)
StartDoMagic(targetFileInfo, targetDirectoryPath, destinationDirectoryPath);
}
}
示例6: ParseFile
protected void ParseFile(FileInfo f, Hashtable h)
{
h[f.GetHashCode().ToString() + "/" + f.Name] = f;
}
示例7: First_Check_LtR
/// <summary>
/// makes any changes done while the app was not running to the remote folder
/// For 'local to remote' mode
/// </summary>
/// <param name="rPath">path to remote ftpbox</param>
/// <param name="path">path to file to be checked</param>
/// <param name="lPath">local path to ftpbox</param>
private void First_Check_LtR(string rPath, string path, string lPath)
{
FileAttributes attr = System.IO.File.GetAttributes(path);
FileInfo fi = new FileInfo(path);
string loc; // = fi.Name;
loc = path.Replace(lPath, "");
loc = loc.Replace(fi.Name, "");
loc = loc.Replace(@"\", @"/");
loc = noSlashes(rPath) + @"/" + noSlashes(loc);
ftp.SetCurrentDirectory(loc);
if ((attr & FileAttributes.Directory) != FileAttributes.Directory)
{
string rDir = path.Replace(lPath, ""); //remove the path to ftpBox from the path
rDir = "/" + noSlashes(loc) + "/" + rDir;
rDir = rDir.Replace(@"\", @"/");
string name = fi.Name;
rDir = rDir.Replace(name, "");
ftp.SetCurrentDirectory(rDir);
if (ftp.FileExists(fi.Name))
{
//string rDir = path.Replace(lPath, ""); //remove the path to ftpBox from the path
//string name = fi.Name; //get the name of the file
//rDir = rDir.Replace(name, ""); //remove the name from the path
//rDir = rDir.Replace(@"\", @"/"); //replace \ with /
//rDir = rPath + "/" + noSlashes(rDir); //get the full path to the new remote directory where the new file will be created
ftp.SetCurrentDirectory(rDir);
FtpFileInfo ftpfi = new FtpFileInfo(ftp, name);
ftpfi.Attributes.GetHashCode();
int rHash = ftpfi.GetHashCode();
int lHash = fi.GetHashCode();
if (rHash == lHash && ftpfi.LastWriteTime != fi.LastWriteTime)
{
ftp.RemoveFile(name);
ftp.PutFile(path, name);
if (ShowNots())
{
tray.ShowBalloonTip(100, "FTPbox", string.Format("File {0} was successfully updated.", name), ToolTipIcon.Info);
}
}
}
else
{
//string name = fi.Name; //get the name of the file
/*
rDir = rDir.Replace(name, ""); //remove the name from the path
rDir = rDir.Replace(@"\", @"/"); //replace \ with /
rDir = rPath + "/" + noSlashes(rDir); //get the full path to the new remote directory where the new file will be created */
ftp.PutFile(path, name);
if (ShowNots())
{
tray.ShowBalloonTip(100, "FTPbox", string.Format("File {0} was successfully uploaded.", name), ToolTipIcon.Info);
}
}
}
else if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
{
string rDir = path.Replace(lPath, ""); //remove the path to ftpBox from the path
string name = fi.Name; //get the name of the file
rDir = "/" + noSlashes(loc) + "/" + rDir;
ftp.SetCurrentDirectory(rDir);
if (!ftp.DirectoryExists(name))
{
/*
rDir = rDir.Replace(name, ""); //remove the name from the path
rDir = rDir.Replace(@"\", @"/"); //replace \ with /
rDir = rPath + "/" + noSlashes(rDir); //get the full path to the new remote directory where the new file will be created */
ftp.CreateDirectory(name);
if (ShowNots())
{
tray.ShowBalloonTip(100, "FTPbox", string.Format("Folder {0} was successfully created.", name), ToolTipIcon.Info);
}
}
}
}