当前位置: 首页>>代码示例>>C#>>正文


C# FileInfo.GetHashCode方法代码示例

本文整理汇总了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
        }
开发者ID:ciker,项目名称:201509LoginDemo,代码行数:49,代码来源:Program.cs

示例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();
 }
开发者ID:SpeedSick,项目名称:PT2016,代码行数:20,代码来源:Program.cs

示例3: RealFile

 public RealFile(FileInfo file)
 {
     _file = file;
     ID = _file.GetHashCode();
 }
开发者ID:Epibatidin,项目名称:FLUX,代码行数:5,代码来源:RealFile.cs

示例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;
        }
开发者ID:raghurana,项目名称:NArrange,代码行数:25,代码来源:Program.cs

示例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);
            }
        }
开发者ID:ukionik,项目名称:EasyIPS,代码行数:63,代码来源:IPSFileConvertionMagic.cs

示例6: ParseFile

 protected void ParseFile(FileInfo f, Hashtable h)
 {
     h[f.GetHashCode().ToString() + "/" + f.Name] = f;
 }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:4,代码来源:MainForm.cs

示例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);
                    }
                }
            }
        }
开发者ID:panyamin,项目名称:FTPbox,代码行数:93,代码来源:fMain.cs


注:本文中的System.IO.FileInfo.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。