16,021,125 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 Visual Basic questions
View Javascript 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 Akshay 007 (Top 4 by date)
Akshay 007
25-Nov-13 21:34pm
View
Sergey,
The Data Types are CHARACTER of length 30, INTERGER (4 byte), FLOAT (4 byte) and CHARACTER of length 30.
The character is similar to FORTRAN 77, where if assign the variable with length 30 then 30 characters will be printed, and the values at indexes can be alphanumeric or blanks. The key here is that even blanks will be printed.
Akshay 007
25-Nov-13 20:53pm
View
Why are you so adamant. If you are a master than download the binary file from https://www.dropbox.com/s/bclgkybavbxpey9/swiss.bin
and try it yourself. Let me also know what different you are doing.
1st value is "Mike Tyson", 2nd value is "1234567890", 3rd value is "1000.50" and last value is "Mike Tyson"
Akshay 007
25-Nov-13 3:50am
View
There are some applications that are made keeping Linux in mind, and these applications use binary format as their input. I don't think you are concentrating on the part where I say while writing the binary file the access mode set is sequential. It is similar to the access="SEQUENTIAL" in Fortran.
I will be using Binary Writer to write the output of my tasks, but it has to be in the same format as is the reader.
Akshay 007
25-Nov-13 2:47am
View
Hi Sergey,
To make things clear I am not using BinaryWriter to create the binary file. As said earlier the file is created on linux with another tool. The method of access is used as sequential for both reading and writing. My task here involves that I need to read that binary file in C# and use these values for further tasks and write the output to another binary file.
The length of my binary file is 40 as per br.BaseStream.Length, the string that is present in the binary file is "Akshay" and was initialized for 30 characters space. The float value inserted is "1000.50" and the int value inserted is "1234567890". All the 3 values are written in same line with tab delimited. When I read it using BinaryReader and as you mentioned about reading the values, I used ReadChars(30) for reading the string of 30 characters, then I used ReadSingle() as an alternative for float as both represent 4 byte floating value, and laslty I used ReadInt32(() as ReadInt64() will go beyond the stream length.
Foll is my code for reading
<pre>
using (var br = new BinaryReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read, 0x10000, FileOptions.SequentialScan)))
{
long pos, length;
length = br.BaseStream.Length;
pos = br.BaseStream.Position;
char[] name = br.ReadChars(30);
pos = br.BaseStream.Position;
float fVal = br.ReadSingle();
pos = br.BaseStream.Position;
Int64 intVal = br.ReadInt64();
pos = br.BaseStream.Position;
}
</pre>
Please help me in understanding where I am making the mistake.