473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

File Dialog to choose a path and file

Hi,

I have a .ASPX page using C# and I need to read in a text file from a
selected path. so in need the file dialog box to allow the user to choose
the path and file that they want to read in.

What command can I use todo this in a .ASPX page, I tried getting it to use
windows that has the file dialog box but cannot get system.window class to
be included in the project.

Thanks,
B Garrett
Nov 17 '05 #1
2 2378
B Garrett,

You can not use System.Windows.Forms in an ASP.NET application because
your code is running on the server side, not the client.

What you want to do is use an input element of type file, I believe (the
html is something like <input type="file">) and it will allow you add a file
browse to the page on the client side, which will then allow a file to be
posted back to the page. The type in ASP.NET that you want to use is the
HtmlInputFile control.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"B Garrett" <bg*****@twacs.com> wrote in message
news:u9**************@TK2MSFTNGP14.phx.gbl...
Hi,

I have a .ASPX page using C# and I need to read in a text file from a
selected path. so in need the file dialog box to allow the user to choose
the path and file that they want to read in.

What command can I use todo this in a .ASPX page, I tried getting it to
use windows that has the file dialog box but cannot get system.window
class to be included in the project.

Thanks,
B Garrett

Nov 17 '05 #2

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ey**************@TK2MSFTNGP09.phx.gbl...
What you want to do is use an input element of type file, I believe
(the html is something like <input type="file">) and it will allow you add
a file browse to the page on the client side, which will then allow a file
to be posted back to the page. The type in ASP.NET that you want to use
is the HtmlInputFile control.


To expand on what Nickolas has pointed out..:

IN MSDN Library:

ms-help://MS.MSDNQTR.2003FEB.1033/Cpqstart/html/cpsmpnetsamples-aspnetservercontrolreference.htm#cpsmpHtmlInputFil e1Sample

Web Link:

http://msdn.microsoft.com/library/en...putfile1sample

Click on the HtmlInputFile1 Sample link.

HTH :)

Mythran

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Martin | last post by:
Again drawing on the groups experience:- 1. For general file opening and file saving, using VB6, are there any issues with using the FileOpen and FileSave Common Dialog Boxes? 2. Is using the...
2
by: Susan Baker | last post by:
Hi, I am (trying) to compile some code I downloaded from the internet. The sources contain references to header files - using the form : #include <pathname/file> If I change the form to...
2
by: John Spiegel | last post by:
Hi all, How does one allow a user to download a file WITH selecting where it should be downloaded to on their machine? Also, when using the WebClient.Download method, will the destination path...
3
by: B Garrett | last post by:
Hi, I have a .ASPX page using C# and I need to read in a text file from a selected path. so in need the file dialog box to allow the user to choose the path and file that they want to read in....
0
by: brian.fairchild | last post by:
I have a downloader page in my asp.net application that looks at a session variable to get the path to the file, checks it then downloads it using the Response object. When the "File Download"...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
3
by: spamsink42 | last post by:
hello how do i create a dialog to allow the user to choose a folder? i tried FolderBrowserDialog but encountered a couple of problems: - when you specify the starting location (property...
7
by: Tim Slattery | last post by:
I'm trying to handle the onChange event in an <input type="file"> element. In IE, there's no problem: the event fires when a file in the "open" box is doubleclicked, or the "Open" button in the box...
2
by: mpalomas | last post by:
Hi C++ folks, I have trouble to open files whose path contains non-ascii characters with std::ifstream. For instance let's say i just have a file which has Japanese characters either in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.