473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to open a .txt file from ASP.NET

Hi group!!! I am new in the ASP.NET programming. I am trying to open a
..txt file but I can't do it.

I am using: but i don't know if its the right way. Thanks for help me.
Dim proc As New System.Diagnostics.Process

proc.Start(file:///C:/bitacora.txt)
Nov 18 '05 #1
8 8254
Here's a quick function to load the entire text file into a string.

private string LoadFile( string file )
{
string contents = "";
using(StreamReader sr = new StreamReader(file))
{
contents = sr.ReadToEnd();
}
return contents;
}

"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi group!!! I am new in the ASP.NET programming. I am trying to open a
.txt file but I can't do it.

I am using: but i don't know if its the right way. Thanks for help me.
Dim proc As New System.Diagnostics.Process

proc.Start(file:///C:/bitacora.txt)

Nov 18 '05 #2
Oh, and the format for calling the LoadFile function might be like:

string filesContents = LoadFile( "c:\\temp\\mytext.txt")

or like

string filesContents = LoadFile(@"c:\temp\mytext.txt") // in this example,
the @ sign automatically escapes the backslashes!

"ESPN Lover" <es**@lover.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
Here's a quick function to load the entire text file into a string.

private string LoadFile( string file )
{
string contents = "";
using(StreamReader sr = new StreamReader(file))
{
contents = sr.ReadToEnd();
}
return contents;
}

"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi group!!! I am new in the ASP.NET programming. I am trying to open a .txt file but I can't do it.

I am using: but i don't know if its the right way. Thanks for help me.
Dim proc As New System.Diagnostics.Process

proc.Start(file:///C:/bitacora.txt)


Nov 18 '05 #3
I think, I din't be clear with the question.

I want to open the .txt file within an aplication... like Notepad, Excel,
etc. Not just read it.

Thanks...

"ESPN Lover" <es**@lover.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
Here's a quick function to load the entire text file into a string.

private string LoadFile( string file )
{
string contents = "";
using(StreamReader sr = new StreamReader(file))
{
contents = sr.ReadToEnd();
}
return contents;
}

"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi group!!! I am new in the ASP.NET programming. I am trying to open a .txt file but I can't do it.

I am using: but i don't know if its the right way. Thanks for help me.
Dim proc As New System.Diagnostics.Process

proc.Start(file:///C:/bitacora.txt)


Nov 18 '05 #4
Where is the application going to be "run" on...client or server?

Once the .txt file is in notepad, what is going to happen to it?
"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I think, I din't be clear with the question.

I want to open the .txt file within an aplication... like Notepad, Excel,
etc. Not just read it.

Thanks...

"ESPN Lover" <es**@lover.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
Here's a quick function to load the entire text file into a string.

private string LoadFile( string file )
{
string contents = "";
using(StreamReader sr = new StreamReader(file))
{
contents = sr.ReadToEnd();
}
return contents;
}

"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi group!!! I am new in the ASP.NET programming. I am trying to open
a
.txt file but I can't do it.

I am using: but i don't know if its the right way. Thanks for help

me. Dim proc As New System.Diagnostics.Process

proc.Start(file:///C:/bitacora.txt)



Nov 18 '05 #5
The application is going to be run on client. And I just want to show the
file on the notepad.

"ESPN Lover" <es**@lover.com> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
Where is the application going to be "run" on...client or server?

Once the .txt file is in notepad, what is going to happen to it?
"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I think, I din't be clear with the question.

I want to open the .txt file within an aplication... like Notepad, Excel,
etc. Not just read it.

Thanks...

"ESPN Lover" <es**@lover.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
Here's a quick function to load the entire text file into a string.

private string LoadFile( string file )
{
string contents = "";
using(StreamReader sr = new StreamReader(file))
{
contents = sr.ReadToEnd();
}
return contents;
}

"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
> Hi group!!! I am new in the ASP.NET programming. I am trying to

open
a
> .txt file but I can't do it.
>
> I am using: but i don't know if its the right way. Thanks for help

me. > Dim proc As New System.Diagnostics.Process
>
> proc.Start(file:///C:/bitacora.txt)
>
>



Nov 18 '05 #6
Even though this seems easy, this is a really difficult task without the
end-user openning the application themselves since if you stream text down,
most browsers will display it as is. Plus, there's no known way to launch
applications on a client's machine via a web page. Who's to say they even
have the application on their computer? Even if they did, it'd be a big
security hole to allow a web page to launch programs on someone's machine.

Tell us what exactly is the requirements are, and there may be other ways to
handle this.
"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
The application is going to be run on client. And I just want to show the file on the notepad.

"ESPN Lover" <es**@lover.com> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
Where is the application going to be "run" on...client or server?

Once the .txt file is in notepad, what is going to happen to it?
"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I think, I din't be clear with the question.

I want to open the .txt file within an aplication... like Notepad, Excel, etc. Not just read it.

Thanks...

"ESPN Lover" <es**@lover.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
> Here's a quick function to load the entire text file into a string.
>
> private string LoadFile( string file )
> {
> string contents = "";
> using(StreamReader sr = new StreamReader(file))
> {
> contents = sr.ReadToEnd();
> }
> return contents;
> }
>
>
>
> "Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
> news:%2***************@TK2MSFTNGP09.phx.gbl...
> > Hi group!!! I am new in the ASP.NET programming. I am trying
to open
a
> > .txt file but I can't do it.
> >
> > I am using: but i don't know if its the right way. Thanks for
help me.
> > Dim proc As New System.Diagnostics.Process
> >
> > proc.Start(file:///C:/bitacora.txt)
> >
> >
>
>



Nov 18 '05 #7
Thanks, Now I understand that is difficult in that way, I'll try showing
the information in a container control.

Thanks again for your time.

"ESPN Lover" <es**@lover.com> wrote in message
news:O6**************@TK2MSFTNGP12.phx.gbl...
Even though this seems easy, this is a really difficult task without the
end-user openning the application themselves since if you stream text down, most browsers will display it as is. Plus, there's no known way to launch
applications on a client's machine via a web page. Who's to say they even
have the application on their computer? Even if they did, it'd be a big
security hole to allow a web page to launch programs on someone's machine.

Tell us what exactly is the requirements are, and there may be other ways to handle this.
"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
The application is going to be run on client. And I just want to show

the
file on the notepad.

"ESPN Lover" <es**@lover.com> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
Where is the application going to be "run" on...client or server?

Once the .txt file is in notepad, what is going to happen to it?
"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I think, I din't be clear with the question.
>
> I want to open the .txt file within an aplication... like Notepad,

Excel,
> etc. Not just read it.
>
> Thanks...
>
> "ESPN Lover" <es**@lover.com> wrote in message
> news:eN**************@TK2MSFTNGP11.phx.gbl...
> > Here's a quick function to load the entire text file into a string. > >
> > private string LoadFile( string file )
> > {
> > string contents = "";
> > using(StreamReader sr = new StreamReader(file))
> > {
> > contents = sr.ReadToEnd();
> > }
> > return contents;
> > }
> >
> >
> >
> > "Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message > > news:%2***************@TK2MSFTNGP09.phx.gbl...
> > > Hi group!!! I am new in the ASP.NET programming. I am trying to open
> a
> > > .txt file but I can't do it.
> > >
> > > I am using: but i don't know if its the right way. Thanks for help me.
> > > Dim proc As New System.Diagnostics.Process
> > >
> > > proc.Start(file:///C:/bitacora.txt)
> > >
> > >
> >
> >
>
>



Nov 18 '05 #8
Having an application on a client-side run is not impossible if you try to
use client script like the following;
'----------------------------------------------
<script language="vbscript">
Sub cmdExcel1_onclick()
set appXl = createobject("excel.application")
With appXl
.Workbooks.Add
.Worksheets.Add
End With

appXl.Visible = True
exlrowCnt = exlrowCnt + 1
appXl.cells.Font.Size = 10
appXl.Columns("A:A").Select
appXl.selection.ColumnWidth = 20
appXl.Columns("B:CZ").Select
appXl.selection.ColumnWidth = 5
appXl.Columns("B:B").Select
appXl.ActiveWindow.FreezePanes = True

appXl.cells(1,1) = 2394023034
End Sub
</script>

<input type=button value="get Excel" name="cmdExcel1">
'----------------------------------------------
the thing is when you try to write a data( calculated or managed by server)
on the client's application.
of course, this can be done by the function "RegisterClientScriptBlock()"
with the asp.net. (refer to the msdn about
"Page.RegisterClientScriptBlock()") thogh,
do i really have to concatenate string values and server-side value together?

i hope any one help me...

"ESPN Lover" wrote:
Even though this seems easy, this is a really difficult task without the
end-user openning the application themselves since if you stream text down,
most browsers will display it as is. Plus, there's no known way to launch
applications on a client's machine via a web page. Who's to say they even
have the application on their computer? Even if they did, it'd be a big
security hole to allow a web page to launch programs on someone's machine.

Tell us what exactly is the requirements are, and there may be other ways to
handle this.
"Juan Manuel AlegrÃ*a B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
The application is going to be run on client. And I just want to show

the
file on the notepad.

"ESPN Lover" <es**@lover.com> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
Where is the application going to be "run" on...client or server?

Once the .txt file is in notepad, what is going to happen to it?
"Juan Manuel AlegrÃ*a B." <jm*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I think, I din't be clear with the question.
>
> I want to open the .txt file within an aplication... like Notepad,

Excel,
> etc. Not just read it.
>
> Thanks...
>
> "ESPN Lover" <es**@lover.com> wrote in message
> news:eN**************@TK2MSFTNGP11.phx.gbl...
> > Here's a quick function to load the entire text file into a string.
> >
> > private string LoadFile( string file )
> > {
> > string contents = "";
> > using(StreamReader sr = new StreamReader(file))
> > {
> > contents = sr.ReadToEnd();
> > }
> > return contents;
> > }
> >
> >
> >
> > "Juan Manuel AlegrÃ*a B." <jm*********@hotmail.com> wrote in message
> > news:%2***************@TK2MSFTNGP09.phx.gbl...
> > > Hi group!!! I am new in the ASP.NET programming. I am trying to open
> a
> > > .txt file but I can't do it.
> > >
> > > I am using: but i don't know if its the right way. Thanks for help me.
> > > Dim proc As New System.Diagnostics.Process
> > >
> > > proc.Start(file:///C:/bitacora.txt)
> > >
> > >
> >
> >
>
>



Nov 19 '05 #9

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

Similar topics

1
by: yanivmad | last post by:
hi I like to ask if there any option to control the html files?!? I have some HTML files at my web site that use one "Help.htm" file for all the pages {I use the "window.open(.... " option at...
9
by: Charles F McDevitt | last post by:
I'm trying to upgrade some old code that used old iostreams. At one place in the code, I have a path/filename in a wchar_t string (unicode utf-16). I need to open an ifstream to that file. ...
6
by: Dino Buljubasic | last post by:
My application creates some temporary files that are deleted when my application terminates. However, if a temp file is open, it will not be deleted and application will crash. How can I...
2
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for...
6
by: qysbc | last post by:
I have a web page and there is a link to open a TIFF file. The way I do it is to have the server code open a binary stream, set the content type to "image/tiff" and call Response.BinaryWrite. On...
2
by: OutdoorGuy | last post by:
Greetings, I have a "newbie" question in relation to opening files from C#. I have a Windows form where I allow the user to type in a file extension in a text box (e.g., "xls"). I then take...
6
by: Moumen VB.NET 2003/2005 Developer | last post by:
How can I detect if a file sitting on a network drive is still open by another application? This application resides on another machine on the network? I am using VB.NET 2003 Your help is...
5
by: Ryan Liu | last post by:
Hi, Both way works, I'd just ask some experts which way is better? My application creates a log file daily. Now each time when I write a log, I will open the file and append to the end....
6
by: Ros | last post by:
There are 10 files in the folder. I wish to process all the files one by one. But if the files are open or some processing is going on them then I do not want to disturb that process. In that case...
0
by: Ofelia | last post by:
Hi, I'm new to this forum and to Perl language but I would like to ask for your help. I'm working in Linux and the files I need to process are in the format “file.gz”. I created a script which...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.