I have the following 2 lines in ASP.NET in VB.NET (For C# just replace the world 'Dim' with 'var') that I got from an example.
Dim tmpFile = Path.GetTempFileName()
Dim tmpFileStream = File.OpenWrite(tmpFile)
I get an error on File.OpenWrite(tmpFile) that says 'Overload resolution failed because no accessible 'File' accepts this number of arguments'. Can anyone explain why this error is happening? I tried looking at documentation and can't seem to figure it out. Thank you.
Notice that the error message is specifying File and not OpenWrite. It looks like there is another File in context which has a higher precedence than System.IO.File. This is likely the source of the error. Try using a fully qualified name here
Dim tmpFileStream = System.IO.File.OpenWrite(tmpFile)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With