0

Im trying make an app that copy the favicon.ico to %temp% file, I have the below code:

string temp = System.IO.Path.GetTempPath();
System.IO.File.WriteAllBytes(temp + "favicon.ico", Properties.Resources.favicon);

But I am receiving the error:

Error 1 The best overloaded method match for 'System.IO.File.WriteAllBytes(string, byte[])' has some invalid arguments

Shwabster
  • 479
  • 1
  • 10
  • 27
Noobes GT
  • 3
  • 4
  • 1
    Maybe because `Properties.Resources.favicon` isn't a `byte[]`? – Rafalon Dec 20 '18 at 14:08
  • it isnt whats why im here i need helps – Noobes GT Dec 20 '18 at 14:09
  • 2
    What type is `Properties.Resources.favicon`? Maybe something like `.ToByteArray()` could work – Rafalon Dec 20 '18 at 14:10
  • its like an room where you drag from desktop to it aplications witch can be runned by the project – Noobes GT Dec 20 '18 at 14:12
  • 3
    like **Rafalon** stated, if `Properties.Resources.favicon` is not a `byte[]`, then you *cannot* use it as a parameter for `File.WriteAllBytes(string, byte[])`. check the type of `Properties.Resources.favicon`. – absoluteAquarian Dec 20 '18 at 14:46
  • The Properties.Resources list won't get your files as binary unless you specify them to on the "favicon" file properties. You will have to either change this or load the image from reflection as a Stream then convert to byte[] (you can write the Stream directly with another IO function though). Please read this: https://stackoverflow.com/questions/9487726/load-resource-as-byte-array-programmatically – EzLo Dec 20 '18 at 15:01

0 Answers0