public void HashAlgorithm_Can_create_same_data_before_and_afterTest2() { String at = @"D:\OIC\IAS\IAS.DataServices.Test\PaymentTest\FileTest"; String result1 = ""; String filetest = Path.Combine(at, "NHibernate_3.pdf"); FileInfo fileInfo = new FileInfo(filetest); if (fileInfo.Exists) { result1 = FileObject.GetHashSHA1(fileInfo.FullName); } String newfile = Path.Combine(fileInfo.DirectoryName, String.Format("newfile{0}.pdf", DateTime.Now.ToString("yyyyMMddhhmmss"))); File.Copy(fileInfo.FullName, newfile); FileInfo fileInfo2 = new FileInfo(newfile); String result2 = ""; if (fileInfo2.Exists) { result2 = FileObject.GetHashSHA1(fileInfo2.FullName); } Assert.AreEqual(result1, result2); }
public DownloadFileResponse Action() { ConnectNetDrive(); DownloadFileResponse response = new DownloadFileResponse(); try { _targetPath = _targetPath.Replace('/', '\\'); System.IO.FileInfo fileInfo = new FileInfo(_targetPath); // check if exists if (!fileInfo.Exists) { throw new FileNotFoundException(Resources.errorDeleteFile_FileNotFound, _fileName); } response.HashCode = FileObject.GetHashSHA1(_targetPath); // open stream System.IO.FileStream stream = new FileStream(_targetPath, FileMode.Open, FileAccess.Read); // ดึง Content Type คืนไปฝั่ง Web ที Consume Service response.ContentType = ContentTypeHelper.MimeType(fileInfo.Name); response.FileName = _fileName; response.Length = fileInfo.Length; response.FileByteStream = stream; response.Code = "0000"; response.Message = Resources.infoDeleteContainer_001; } catch (Exception ex) { response.Code = "0001"; response.Message = ex.Message; } finally { DisConnectNetDrive(); } return(response); }