System.Web.UI.HtmlControls.HtmlInputFile
Asp.net File Upload.
The fact that you're using a control that's meant for a Windows form client
application in the middle of a Web form application is questionable.
Where is your code running?
Is it on the server?
Perhaps that's why it can't see the C drive of the users machine and
are gettign errors
Do not use Windows controls on a web page. If they work at all, it
will not be as you expect. Hence the way the dialog is being
displayed. They are not designed to work on web pages. That is why
there is a completely different set of controls for web pages.
Directly linking to a local resource on a webpage is definitely a bad
practice with all sorts of security holes. Browsers and languages
(client side) will stop most access to most files for security/privacy
reasons.
The file upload control is the way to get local file path names on a
web page. You don't have to upload the file, but you can't do much
else with it.
If you want to display a locally held image on a web page it must be
first uploaded to a site.
Herfried K. Wagner [MVP] - 06 Jul 2007 18:03 GMT
"Matt Lacey" <m.lacey@fdsltd.co.uk> schrieb:
> Where is your code running?
> Is it on the server?
> Perhaps that's why it can't see the C drive of the users machine and
> are gettign errors
>
> Do not use Windows controls on a web page.
I agree for Web sites, but for an intranet site, this may be appropriate in
certain scenarios. Nevertheless, you cannot use the classes without any
problems directly in your code because it is executed on the server and not
on the client. Thus the dialog would (in theory) be shown on the server.
What can be done is developing a Windows Forms Browser Control that hosts
the OpenFileDialog and is used to show it.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
>I want to open a file using OpenFile Dialog class (System.Windows.Forms) in
> my ASP.NET application . I don't want to use file upload control why
[quoted text clipped - 17 lines]
> Image1.ImageUrl = of.FileName.ToString();
> }
Where do you run the code? server side or client side? Since you use C#, I
assmue it is server side code (ASP.NET code). So, you actually show the
OpenFile dialog on the server.
> It is working fine my system and when the same code runs in a different
Works fine on your computer? I'd bet you are testing youe ASP.NET app on
your local IIS and the OpenFile dialog is opened by the IIS, not your
browser. Try to test your ASP.NET app from other computer's browser (that
is, the IIS server and browser on different computer) to see what happens.
> computer I am getting the below error
>
[quoted text clipped - 9 lines]
>
> Can any one suggest the solution for this.
The suggestion is No, you cannot use OpenFile dialog on the server side
(even you can, your ASP.NET users on the other side of town/world, have to
rush into the server room, find the server's monitor (the server may not
have one!) and pick a file (on the server!) and click OK, rush back to his
computer (maybe days later) and continue.
If you really want to replace the File Upload dialog on the client side with
something more customized, you can make a Win Form User Control to wrap up
the OpenFile dialog inside and embed it into the ASP.NET page as
<Object>...</Object>, similar to use ActiveX Controls in web page. However,
in this case, user must have .NET framework installed and the Browser has to
be set to allow download the code and install it (user has to answer some
security questions he possibly does not understand at all before it can be
installed. Chances are the installation be stopped).
> Thanks in advance Umeshnath