Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
QuestionArticle "tip/trick "Converting Enum member names and values in C#"" Pin
Сергій Ярошко16-Feb-21 22:46
professionalСергій Ярошко16-Feb-21 22:46 
AnswerRe: Article "tip/trick "Converting Enum member names and values in C#"" Pin
PIEBALDconsult17-Feb-21 3:17
mvePIEBALDconsult17-Feb-21 3:17 
GeneralRe: Article "tip/trick "Converting Enum member names and values in C#"" Pin
Сергій Ярошко17-Feb-21 4:13
professionalСергій Ярошко17-Feb-21 4:13 
GeneralRe: Article "tip/trick "Converting Enum member names and values in C#"" Pin
Richard Deeming17-Feb-21 4:31
mveRichard Deeming17-Feb-21 4:31 
GeneralRe: Article "tip/trick "Converting Enum member names and values in C#"" Pin
PIEBALDconsult17-Feb-21 5:19
mvePIEBALDconsult17-Feb-21 5:19 
QuestionHow C# handles binary files? Pin
Member 1477325816-Feb-21 21:59
Member 1477325816-Feb-21 21:59 
AnswerRe: How C# handles binary files? Pin
Richard MacCutchan16-Feb-21 22:11
mveRichard MacCutchan16-Feb-21 22:11 
AnswerRe: How C# handles binary files? Pin
OriginalGriff16-Feb-21 22:39
mveOriginalGriff16-Feb-21 22:39 
You very definitely don't read binary file data with ReadAllText - you need ReadAllBytes[^] which returns a byte[] instead of a string.

Strings are made of characters, which are generally variable length: they could be 8 bit, they could be 16 - and reading binary data as text is a very good way to corrupt it beyond hope of recovery.

This may help: ByteArrayBuilder - A StringBuilder for Bytes[^] it allows you to apply some "structure" to a binary file and read it in a "sensible" way. If nothing else, it shows one way to handle binary data files, but if your data files already exist and you must read them, then you will probably need to take a good hard look at the file format before you get started - there will be a structure applied to it, but what structure depends on the developer who produced them!

If you are to produce your own dtaa files, then it's probably a better idea to look at using JSON or even XML instead of binary data - it's much, much easier to handle I/O as both can "fill classes" for you when your read or write the data. Saves a whole load of work!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

AnswerRe: How C# handles binary files? Pin
Gerry Schmitz17-Feb-21 6:00
mveGerry Schmitz17-Feb-21 6:00 
QuestionC#, loop statement Pin
Jennalyn Nayoyos15-Feb-21 2:57
Jennalyn Nayoyos15-Feb-21 2:57 
AnswerRe: C#, loop statement Pin
OriginalGriff15-Feb-21 3:16
mveOriginalGriff15-Feb-21 3:16 
AnswerRe: C#, loop statement Pin
Richard MacCutchan15-Feb-21 4:53
mveRichard MacCutchan15-Feb-21 4:53 
AnswerRe: C#, loop statement Pin
Gerry Schmitz15-Feb-21 6:10
mveGerry Schmitz15-Feb-21 6:10 
QuestionRe: C#, loop statement Pin
Kenneth Haugland15-Feb-21 19:42
mvaKenneth Haugland15-Feb-21 19:42 
AnswerRe: C#, loop statement Pin
Richard MacCutchan15-Feb-21 21:13
mveRichard MacCutchan15-Feb-21 21:13 
QuestionWITSML Server And Client in C# Pin
Member 1332584614-Feb-21 21:59
Member 1332584614-Feb-21 21:59 
AnswerRe: WITSML Server And Client in C# Pin
Richard MacCutchan14-Feb-21 22:18
mveRichard MacCutchan14-Feb-21 22:18 
GeneralRe: WITSML Server And Client in C# Pin
Member 1332584614-Feb-21 22:51
Member 1332584614-Feb-21 22:51 
Question[solved] Two-way binding winforms checkbox to property? Pin
RobertSF14-Feb-21 6:21
professionalRobertSF14-Feb-21 6:21 
AnswerRe: Two-way binding winforms checkbox to property? Pin
Gerry Schmitz14-Feb-21 6:37
mveGerry Schmitz14-Feb-21 6:37 
GeneralRe: Two-way binding winforms checkbox to property? Pin
RobertSF14-Feb-21 7:42
professionalRobertSF14-Feb-21 7:42 
GeneralRe: Two-way binding winforms checkbox to property? Pin
Gerry Schmitz14-Feb-21 8:20
mveGerry Schmitz14-Feb-21 8:20 
QuestionNeed code to download file from FTP with Auto Resume functionality in case of Internet disconnection. Pin
Member 1507143012-Feb-21 6:00
Member 1507143012-Feb-21 6:00 
AnswerRe: Need code to download file from FTP with Auto Resume functionality in case of Internet disconnection. Pin
Gerry Schmitz12-Feb-21 9:19
mveGerry Schmitz12-Feb-21 9:19 
AnswerRe: Need code to download file from FTP with Auto Resume functionality in case of Internet disconnection. Pin
Mycroft Holmes12-Feb-21 10:08
professionalMycroft Holmes12-Feb-21 10:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.