Hello,

I have a void that goes like this private void Blah(Stream File)

Then When I go to use it I want to use it like this Blah(path)

The path represents a file.name.

It is real complicated. I mean over a 1000 lines of code for the Blah(Stream File)

The Error I am getting is:

Error	2	Argument 1: cannot convert from 'string' to 'System.IO.Stream'	C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Lucky Se7en\Lucky Se7en\Resigner.cs	170	59	Lucky Se7en

Recommended Answers

All 3 Replies

You are passing in a filename as a string where the method signature expects a stream value. Either change the method to:

private void Blah(string path)
{
    Stream s = new Stream(path);
}

Writing on the fly here so apologies if the stream syntax is off. Basically pass in the string then create your stream.
Alternatively, you need to create your stream and pass that to the method:

Stream s = new Stream(path);
Blah(s);

Thanks for the reply. This is the code im using...

public STFSCon(string File)
        {
            Stream ConFile = new Stream(File);
            
        }

Now I get a error...

Cannot create an instance of the abstract class or interface 'System.IO.Stream'

Told you my Stream syntax was probably wrong :p
Stream is an abstract class; you cannot directly create an instance of it. You need to create an instance of one of its derived classes such as System.IO.FileStream

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.