|
Unfortunaltely thats the way split works, you need to write some looping code to do what you require. Have a look at string.IndexOf
Hope this helps
Bob
Ashfield Consultants Ltd
|
|
|
|
|
rahuladya wrote: string[] b = new string[10];
b=a.Split('a');
Why do you create an array and assign to the b variable, when you are assigning a new variable to it on the next line?
rahuladya wrote: i want to get
b[0]=a
b[1]=dv
b[2]=a
b[3]=nced
You can use a regular expression to split the string:
string a = "advanced";
string[] b = Regex.Split(a, "(a)");
Or for any string you like:
string a = "advanced";
string splitter = "a";
string[] b = Regex.Split(a, "(" + Regex.Escape(splitter) + ")");
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Nice one. Never thought of regex.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Thanx Guffa
it works very well...
regards
Rahul adya
|
|
|
|
|
hi
I am copying file from USB to my hard drive using C#.net Window application
now after copying i want to verify if copied file is same or not.Is there any way to verify it. or is there any way to generate HASH key of a file in order to verify it. As hash key is unique for every file.
Thanks In Advance
|
|
|
|
|
There are many hashing algorithms. Which one do you want to use? System.Security.Cryptography namespace contains hashing related classes.
|
|
|
|
|
Can u give me a sample code to fine hash key of one file
so that i can compare it with other to check if they r same or not.
thanks
|
|
|
|
|
You need to read file in byte array and call ComputeHash method of the hasher class you choose. MSDN has several examples, why don't you read the documentation?
|
|
|
|
|
It doesn't matter what .NET language you use, the method is the same.
The same thread, but in the VB forum[^]
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
How do you know you won't get errors when you read the file while hashing it that hides any errors caused by copying? :P
|
|
|
|
|
I will match the hash key of source file and target file
|
|
|
|
|
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
|
|
|
|