Yuav Ua Li Cas Thiaj Ua Cov Ntaub Ntawv Bin

Cov txheej txheem:

Yuav Ua Li Cas Thiaj Ua Cov Ntaub Ntawv Bin
Yuav Ua Li Cas Thiaj Ua Cov Ntaub Ntawv Bin

Video: Yuav Ua Li Cas Thiaj Ua Cov Ntaub Ntawv Bin

Video: Yuav Ua Li Cas Thiaj Ua Cov Ntaub Ntawv Bin
Video: Qhia tawm laug hais paj ntaub cog ci By Pakou Her 2024, Kaum ib hlis
Anonim

Cov ntaub ntawv binary yog qhov sau tau ua qauv sau nrog daim *. BIN ncua ntxiv. Cov hom ntaub ntawv no yog siv rau hauv cov ntawv thov cov kev pab cuam thiab muaj cov ntaub ntawv hais txog cov software. Koj tuaj yeem khaws cov ntaub ntawv twg: cov hlua, cov lej lossis booleans - thiab cim cov ntaub ntawv.

Yuav ua li cas thiaj ua cov ntaub ntawv bin
Yuav ua li cas thiaj ua cov ntaub ntawv bin

Tsim nyog

  • - Cov kev txawj programming;
  • - khoos phis tawj.

Cov Lus Qhia

Kauj ruam 1

Muab koj nplooj ntawv qhov project nplooj lub npe tsim nyog. Cov ntawv sau thiab nyeem cov ntaub ntawv yuav tsum siv cov npe "IO", raws li cov chav nyeem ntawv uas siv los ntawm kev tsim tawm raug hu ua. Cov ntawv sau yuav tsum muaj chav kawm nyob hauv I / O zog hloov. Ntxiv kab hauv qab no ntxiv rau thaum pib ntawm cov code code: "suav nrog System. IO;".

Kauj ruam 2

Tsim cov ntaub ntawv tsim tawm thiab muab cov binary tus nqi rau qhov sib txawv. Qhov no yuav tsim cov ntawv binary, tab sis tam sim no nws yuav tas. Binaries tuaj yeem tsim nrog nrog txuas ntxiv, tab sis *. BIN yog tus qauv ib. Siv cov cai hauv qab no los tsim cov ntaub ntawv binary: "FileStream file = FileStream tshiab (" C: / mybinaryfile.bin ", FileMode. Create); BinaryWriter binarystream = BinaryWriter tshiab (cov ntaub ntawv); ".

Kauj ruam 3

Ntxiv qhov sau ua haujlwm rau hauv binary cov ntaub ntawv siv cov lus "Sau". Qhov haujlwm no cia li encode cov nqi hauv hom binary, yog li koj tsis tas yuav encode cov ntaub ntawv ua ntej txuag nws mus rau ib qho ntaub ntawv. Hauv qab no yog ib qho piv txwv ntawm kev sau ntawv mus rau binary file: “binarystream. Write (“Kuv li binary thawj cov ntawv”);

binarystream. Write (10);"

Kauj ruam 4

Kaw cov ntaub ntawv kom sai li sai tau tag nrho cov ntaub ntawv tsim nyog tau raug cawm cia rau nws. Kaw cov ntaub ntawv tseem ceeb heev nyob rau hauv lub cajmeem vim nws xaus cov txheej txheem tsim cov ntaub ntawv thiab qhib nws rau siv los ntawm cov neeg siv lossis lwm yam kev siv. Cov kab txuas ntxiv kaw lub binary thiab txuag nws kom lub hard drive: "binarystream. Close ();"

Kauj ruam 5

Kuaj cov ntaub ntawv binary. Khiav daim ntawv thov, cov ntaub ntawv hais txog uas koj tau muab tso rau hauv cov ntaub ntawv tsim. Yog tias txhua yam ua haujlwm flawlessly, tom qab ntawd tus lej tso ua ke yog qhov tseeb. Txwv tsis pub, siv debug ua haujlwm ntawm cov ntaub ntawv binary, nco ntsoov yog hais tias cov cai tswj tau sau kom raug.

Pom zoo: