C# convert string into its byte[] equivalent

后端 未结 6 1811
北恋
北恋 2021-01-05 06:10

At this point most people will be thinking \"Ah ill post this..:\"

byte[] dataB= System.Text.Encoding.ASCII.GetBytes(data);

However.. the p

6条回答
  •  被撕碎了的回忆
    2021-01-05 07:02

    Why convert from string at all? Couldn't you just read the contents of the file directly into bytes?

    byte[] fileC = File.ReadAllBytes(dialog.FileName);
    

提交回复
热议问题