|
What Mark means (if I'm not mistaken) is that if you get a read error when you copy the file, you are likely to get the same read error when you verify the file. So you will only be verifying the write part of the copy operation, not the read part.
To truly verify the operation, you would have to create the hash code from the original data when the original file was created.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yep. Basically if you can't trust the USB disk to keep the data uncorrupted hashing when you read it won't help you. You'll just be checking that the Windows copy function works, which is kinda pointless.
|
|
|
|
|
|
1 vote countered with a 5.
|
|
|
|
|
|
public bool CompareFiles(string sourceFile, string destinationFile)
{
try
{
//Open our files for reading
Stream _sourceFile = File.OpenRead(sourceFile);
Stream _destinationFile = File.OpenRead(destinationFile);
//Create a new instance of one of the MD5 classes
MD5CryptoServiceProvider MD5Alg = new MD5CryptoServiceProvider();
//We will use the ComputeHash method to get our hash values of each file
byte[] SourceFileHash = MD5Alg.ComputeHash(_sourceFile);
byte[] DestinationFileHash = MD5Alg.ComputeHash(_destinationFile);
//Done reading so close the files
_sourceFile.Close();
_destinationFile.Close();
//Where going to use the BitConverter and convert the hash values into a string for a quick,
//down and dirty compare.
string SourceFileHashKey = BitConverter.ToString(SourceFileHash);
string DestinationFileHashKey = BitConverter.ToString(DestinationFileHash);
//Return the match
return (SourceFileHashKey == DestinationFileHashKey);
}
|
|
|
|
|
hey, i need to get folder alias from exchange 2003 using c#
i tried to use webdav and select query but i didnt succeed .
i'd like if some one can spill some light on this one
|
|
|
|
|
Hello everyone,
I am using VS 2008 and writing a console project. I add a new web reference to a web services and it is successful. I have found Web Reference folder is generated and there is a file called Reference.cs containing proxy class.
My question is, how to use the proxy class in Reference.cs? Add this cs file manually to my project? If yes, add to which folder of the project?
thanks in advance,
George
|
|
|
|
|
The web reference folder is already within your project, right?
Just create an instance of the class in your code, and use that object to call the web service.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks Guffa!
1.
I have got your idea. But we still need to add using XXX in order to support to use the proxy class in related cs files, correct?
2.
It does not matter if the proxy class cs file does not appear in IDE?
regards,
George
|
|
|
|
|
1 - Your question is not clear. When you add reference to a WS, VS editor automatically generates proxy classes for it. You use these classes to do communication.
2 -
|
|
|
|
|
Thanks N a v a n e e t h!
Let me clarify.
1.
I mean we need to add "using <proxy class="" name="">" in other cs file, where we need to use the proxy class, correct? (my question is, IDE does not add reference automatically in the project, so we need to add using statement manually in each cs file where we need to use the proxy class);
2.
In "Solution Explorer" of Visual Studio, the generaed file Reference.cs does not exist. But it does not block us to use it in current project by add using statement in related cs files use the proxy class, correct?
regards,
George
|
|
|
|
|
George_George wrote: so we need to add using statement manually in each cs file where we need to use the proxy class)
YES.
2 - That file exists in the project folder. VS editor just hides it to prevent users editing it manually. Just click on "Goto definition" on any WS types, you can see the proxy class opens.
|
|
|
|
|
Cool, N a v a n e e t h!
Question answered.
regards,
George
|
|
|
|
|
If I understand your question correct you're trying to use the using clause to automatically dispose the instance of the class on the web reference you're creating right? You dont need to worry about the proxy class, just use the web reference exactly like you would use any normal dll reference.
|
|
|
|
|
Sorry, my English is bad. I mean I want to use "using" statement which is at the beginning of each cs file to import the namespace of the proxy class.
regards,
George
|
|
|
|
|
You will need to know the namespace that the classes you want to reference lays in. You use that namespace with the using clause at the top of your class:
eg.
namespace SampleNamespace
{
public class SampleClass
{
public static object oValue;
}
}
This you can use as:
using Samplenamespace;
public class Foo
{
public void Boo()
{
object sampleValue = SampleClass.oValue;
}
}
Hope this answers your question.
|
|
|
|
|
Thanks bcozican,
My question answered.
regards,
George
|
|
|
|
|
Hi all,
I would like to know when making use of the 'using' keyword and an exception occurred, will the exception be catered for in the 'using' scope?
Thus, if one would look at the following example(s), and lets say an exception occurred within the 'using' block below, will the exception be catched?:
Font font1 = new Font("Arial", 10.0f);
try
{
byte charset = font1.GdiCharSet;
}
finally
{
if (font1 != null)
((IDisposable)font1).Dispose();
}
using (Font font3 = new Font("Arial", 10.0f), font4 = new Font("Arial", 10.0f))
{
}
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
|
Thanks...
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
You are welcome
|
|
|
|
|
It will be caught, eventually, but not by your try/catch block as shown. If you want your 'using' exceptions caught then the using needs to be in a try/catch block.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Ashfield wrote: If you want your 'using' exceptions caught then the using needs to be in a try/catch block.
Thanks that was helpful...
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
The using block generates a try...finally block. That ensures that the object is disposed even if an exception occurs, but it doesn't catch any exceptions.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|