16,017,922 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by BrianHamilton (Top 26 by date)
BrianHamilton
7-Feb-15 11:27am
View
Deleted
Code will not post properly for some reason: hope this works
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>File API</title>
<script>
function processFiles()
{
var filelist = document.getElementById('files').files;
for(var i=0; i<filelist.length; i++)
="" {
=""
="" var="" file="filelist[i];
" texttype="/text.*/;
"
="" if="" (file.type.match(texttype))="" {="" reader="new" filereader();
="" reader.="">
</head>
<body>
Select a text file:
<input type="file" multiple id="files" />
</body>
</html>
BrianHamilton
7-Feb-15 11:14am
View
The code will not allow me to open multiple files - if I add the multiple attribute it will still only display the contents of the last file selected rather than the contents of all files.
BrianHamilton
10-Nov-14 5:59am
View
Objects are passed by reference, not value. Thanks!
BrianHamilton
24-Nov-13 8:30am
View
That worked - I tried dividing by 2, 2.2, 2.5 ... and it turns out the code was working - my brain wasn't. Thanks for the help.
Brian.
BrianHamilton
7-Aug-13 0:11am
View
Show the code you have written so far.
BrianHamilton
12-Apr-13 15:38pm
View
That's a lot of questions and seems like a strange way to develop your application. Why not write some code and post it. You could take a different approach to the web service.
BrianHamilton
21-Feb-13 14:50pm
View
Would need to see your code but you could use a regular expression, String.split or a variation of substr and indexOf()
BrianHamilton
17-Feb-13 14:32pm
View
Your statement makes no sense - if everyone learned the language (learning the language as you put it) - there would be no need for this site. No-one is required to reply to any question and I do not believe I have broken any site rules.
BrianHamilton
16-Feb-13 16:08pm
View
Works perfectly, thanks a million. Brian.
BrianHamilton
16-Feb-13 13:03pm
View
void ProcessStudent(Student stu[], int Cnt) as opposed to void ProcessStudent(Student * stu[], int Cnt)but other than that, works fine. Thanks!
BrianHamilton
18-Sep-12 13:59pm
View
Yes that works perfectly - I had been under the impression passing a form to a method was to be avoided, but I assume this is better than making form elements public?
BrianHamilton
18-Sep-12 12:48pm
View
will repost.
BrianHamilton
18-Sep-12 12:17pm
View
Deleted
yes they do. Display details works fine.
BrianHamilton
16-Sep-12 13:30pm
View
Got it working - Thans
BrianHamilton
16-Sep-12 10:45am
View
I get what you are saying but if I put the above in my class, it will not recognise the textboxes, is it supposed to go in the form?
BrianHamilton
16-Sep-12 10:02am
View
The error is: An unhandled exception of type 'System.StackOverflowException' occurred in ManageStudentsWin.exe. The line it occurs on is
Form1 details = new Form1();
How do I pass an instance of the form to the class? I had looked on the web but didn't see anything about that.
BrianHamilton
14-Sep-12 6:36am
View
Yes, and I think it was yourself that provided a fully working version (as shown below) - I assume the MD5 on wiki is the exception as all other files work fine with the other program - I just found the solution below a little hard to understand - I've usually done encrypting/decrypting with no problems whether it be string or files, but I get that wikipedia were showing a representation of a binary file that probably exists somewhere..
<pre>
static void Main(string[] args)
{
byte[] myBytes1 = ReadHexFile("FileA.txt");
byte[] myBytes2 = ReadHexFile("FileB.txt");
using (MD5 md5Hash = MD5.Create())
{
string hash1 = GetMd5Hash(md5Hash, myBytes1);
string hash2 = GetMd5Hash(md5Hash, myBytes2);
Console.WriteLine("The MD5 hash of " + string.Join("", myBytes1.Select(b => b.ToString("x2"))) + " is: " + hash1 + ".");
Console.WriteLine("The MD5 hash of " + string.Join("", myBytes1.Select(b => b.ToString("x2"))) + " is: " + hash2 + ".");
}
Console.ReadLine();
}
static string GetMd5Hash(MD5 md5Hash, byte[] input)
{
byte[] data = md5Hash.ComputeHash(input);
return string.Join("", data.Select(b => b.ToString("x2")));
}
static byte[] ReadHexFile(string path)
{
System.IO.FileStream fs1 = System.IO.File.OpenRead(path);
System.IO.StreamReader sr1 = new System.IO.StreamReader(fs1);
string hexString = sr1.ReadToEnd();
hexString = System.Text.RegularExpressions.Regex.Replace(hexString, @"\W", "", System.Text.RegularExpressions.RegexOptions.Singleline);
int ix = 0;
byte[] myBytes1 = new byte[hexString.Length / 2];
while (ix < hexString.Length)
{
string hexByte = hexString.Substring(ix, 2);
myBytes1[ix / 2] = byte.Parse(hexByte, System.Globalization.NumberStyles.HexNumber);
ix += 2;
}
return myBytes1;
}
</pre>
BrianHamilton
13-Sep-12 14:42pm
View
Isn't that more concurrent programming? Parallel programming concerns operations that are overlapped for the specific goal of improving throughput.
BrianHamilton
27-Aug-12 11:41am
View
Apologies, of course - It's working now. Thanks for the link and explanation.
BrianHamilton
27-Aug-12 9:39am
View
I see what you mean, but the async GUI code functions perfectly.
BrianHamilton
27-Aug-12 8:55am
View
Have altered above code as follows:
[STAThreadAttribute]
public void syncRead()
{
//OpenFileDialog ofd = new OpenFileDialog();
//ofd.ShowDialog();
openFileDialog.ShowDialog();
FileStream fs;
When I run program and click the ReadSync button, the file open dialog box does not show up - it didn't before either.
BrianHamilton
21-Aug-12 16:06pm
View
Works perfectly...Thanks
BrianHamilton
21-Aug-12 12:18pm
View
Above solution works fine - just used binary files to get the hash collisions working.
BrianHamilton
21-Aug-12 10:31am
View
This code works as well when I convert the byte array into a string, but I'm still getting different hash values for the files.
BrianHamilton
21-Aug-12 9:30am
View
The program works in terms of getting hash values, but they are not identical, which they are in the C program. I have altered the wiki inputs in my text files as an exact copy of the ones below and now program crashes:
http://en.wikipedia.org/wiki/MD5
FileA:
d131dd02c5e6eec4 693d9a0698aff95c 2fcab58712467eab 4004583eb8fb7f89
55ad340609f4b302 83e488832571415a 085125e8f7cdc99f d91dbdf280373c5b
d8823e3156348f5b ae6dacd436c919c6 dd53e2b487da03fd 02396306d248cda0
e99f33420f577ee8 ce54b67080a80d1e c69821bcb6a88393 96f9652b6ff72a70
FileB:
d131dd02c5e6eec4 693d9a0698aff95c 2fcab50712467eab 4004583eb8fb7f89
55ad340609f4b302 83e4888325f1415a 085125e8f7cdc99f d91dbd7280373c5b
d8823e3156348f5b ae6dacd436c919c6 dd53e23487da03fd 02396306d248cda0
e99f33420f577ee8 ce54b67080280d1e c69821bcb6a88393 96f965ab6ff72a70
BrianHamilton
21-Aug-12 7:09am
View
Well, the code below is the umpteenth version:
static void Main(string[] args)
{
System.IO.StreamReader myFile1 = new System.IO.StreamReader("FileA.txt");
System.IO.StreamReader myFile2 = new System.IO.StreamReader("FileB.txt");
string myString1 = myFile1.ReadToEnd();
string myString2 = myFile2.ReadToEnd();
using (MD5 md5Hash = MD5.Create())
{
string hash1 = GetMd5Hash(md5Hash, myString1);
string hash2 = GetMd5Hash(md5Hash, myString2);
Console.WriteLine("The MD5 hash of " + myString1 + " is: " + hash1 + ".");
Console.WriteLine("The MD5 hash of " + myString2 + " is: " + hash2 + ".");
}
}
static string GetMd5Hash(MD5 md5Hash, string input)
{
byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
return data.ToString();
}
Show More