Re: Can't pass "[System.IO.FileMode]::Open" as a Constructor argument of "FileStream"
- From: "Bruce Payette [MSFT]" <brucepay@xxxxxxxxxxxxx>
- Date: Fri, 9 Dec 2005 10:02:00 -0800
> wouldn't you need to use quotes if your path contained spaces?
Yes, you need to use quotes if the argument is going to contain any
characters that are significant to the interpreter.
> doesn't this make it very hard to resolve to the correct member overload?
It certainly does. We use a very complex set of heuristics to determine what
constructor to run.
> Eww. I think I will stick with expression mode (parens) and be a bit
> more explicit. :-)
Agreed - expression mode let's you be very explicit. This is an excellent
point. In fact we'll probably add this as a script writer best practice in
the guidelines we're working on. Thanks.
-bruce
--
Bruce Payette [MSFT]
Microsoft Command Shell Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
"Keith Hill" <r_keith_hill@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:eFdCXp7%23FHA.984@xxxxxxxxxxxxxxxxxxxxxxx
> "Bruce Payette [MSFT]" <brucepay@xxxxxxxxxxxxx> wrote in message
> news:u%23Zq5q4%23FHA.1408@xxxxxxxxxxxxxxxxxxxxxxx
>> What's happening here is that new-object gets 2 arguments - a string
>> naming the type to be constucted and a list of strings to used as
>> arguments to the object constructor. The cmdlet parameter binder looks at
>> these argument strings and converts them into the necessary target
>> objects. Because we're parsing in argument mode, the quotes aren't
>> required and unquoted tokens are treated as strings.
>
> Thanks! This is really good stuff to know. A couple of points. First,
> wouldn't you need to use quotes if your path contained spaces? Second,
> doesn't this make it very hard to resolve to the correct member overload?
> I mean, you have a bunch of strings and then you have to figure out which
> one of potentially many overloads can be type coerced to from string args.
> And even then you could have several overloads that match by coercing the
> string args to various other types. Doesn't that leave you with some form
> of heuristic to pick the best match? Eww. I think I will stick with
> expression mode (parens) and be a bit more explicit. :-)
>
> --
> Keith
>
>
.
- Follow-Ups:
- Re: Can't pass "[System.IO.FileMode]::Open" as a Constructor argument of "FileStream"
- From: DontBotherMeWithSpam
- Re: Can't pass "[System.IO.FileMode]::Open" as a Constructor argument of "FileStream"
- References:
- Can't pass "[System.IO.FileMode]::Open" as a Constructor argument of "FileStream"
- From: DontBotherMeWithSpam
- Re: Can't pass "[System.IO.FileMode]::Open" as a Constructor argument of "FileStream"
- From: Keith Hill
- Re: Can't pass "[System.IO.FileMode]::Open" as a Constructor argument of "FileStream"
- From: /\\/\\o\\/\\/
- Re: Can't pass "[System.IO.FileMode]::Open" as a Constructor argument of "FileStream"
- From: Bruce Payette [MSFT]
- Re: Can't pass "[System.IO.FileMode]::Open" as a Constructor argument of "FileStream"
- From: Keith Hill
- Can't pass "[System.IO.FileMode]::Open" as a Constructor argument of "FileStream"
- Prev by Date: Re: How to Monitor CPU usage in MSH
- Next by Date: RE: How to Monitor CPU usage in MSH
- Previous by thread: Re: Can't pass "[System.IO.FileMode]::Open" as a Constructor argument of "FileStream"
- Next by thread: Re: Can't pass "[System.IO.FileMode]::Open" as a Constructor argument of "FileStream"
- Index(es):
Relevant Pages
|